### Start Marzban service Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Initiates and turns on the Marzban service, making it operational. ```Shell marzban up ``` -------------------------------- ### Start Marzban-node service Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Initiates and turns on the Marzban-node service, making it operational. ```Shell marzban-node up ``` -------------------------------- ### Setup Marzban backup service Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Configures and sets up the automated backup service for Marzban. ```Shell marzban backup-service ``` -------------------------------- ### Install Marzban Node Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs the Marzban-node component on your server. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install ``` -------------------------------- ### Install Marzban Panel Command Script Only Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs only the `marzban` command script on your server, without performing a full panel installation. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install-script ``` -------------------------------- ### Edit Marzban-node Docker configuration Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Opens the configuration file for Marzban-node's Docker setup for editing. ```Shell marzban-node edit ``` -------------------------------- ### Install and Enable Marzban Systemd Service Source: https://gozargah.github.io/marzban/en/docs/introduction/installation These commands make the `install_service.sh` script executable, run it to install Marzban as a systemd service, and then enable and immediately start the service to run in the background. ```bash sudo chmod +x install_service.sh sudo ./install_service.sh sudo systemctl enable --now marzban.service ``` -------------------------------- ### Edit Marzban Docker configuration Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Opens the configuration file for Marzban's Docker setup for editing. ```Shell marzban edit ``` -------------------------------- ### Install Marzban Panel with SQLite Database Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs the Marzban Panel on your server using the SQLite database, which is suitable for small numbers of users and nodes. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install ``` -------------------------------- ### Install Marzban Node Command Script Only Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs only the `marzban-node` command script on your server, without performing a full node installation. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install-script ``` -------------------------------- ### View Marzban CLI Help Source: https://gozargah.github.io/marzban/en/docs/introduction/installation Execute this command to display the Marzban command-line interface (CLI) guide, showing all available commands and options for managing your Marzban instance. ```bash marzban --help ``` -------------------------------- ### Install Marzban Panel with MySQL Database Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs the Marzban Panel on your server using the MySQL database, which is strongly recommended for a large number of users and nodes. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --database mysql ``` -------------------------------- ### View All Marzban Node Commands Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Displays a list of all available commands for the Marzban-node script. ```bash marzban-node help ``` -------------------------------- ### Install Specific Marzban Panel Version with MariaDB Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs a specific version of the Marzban Panel (e.g., v0.5.2) on your server using the MariaDB database. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --database mariadb --version v0.5.2 ``` -------------------------------- ### View All Marzban Panel Commands Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Displays a list of all available commands for the Marzban Panel script. ```bash marzban help ``` -------------------------------- ### Install Marzban with Quick Installation Script Source: https://gozargah.github.io/marzban/en/docs/introduction/installation This command executes the Marzban quick installation script, which automatically installs Docker and sets up Marzban. It makes the `marzban` command available system-wide and configures data storage in `/var/lib/marzban` and application files in `/opt/marzban`. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install ``` -------------------------------- ### Update Marzban installation Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Updates the Marzban installation to the latest available version. ```Shell marzban update ``` -------------------------------- ### Install Marzban Panel with MariaDB Database Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs the Marzban Panel on your server using the MariaDB database. This option should only be used if you have sufficient knowledge of working with MariaDB. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --database mariadb ``` -------------------------------- ### Take immediate Marzban backup Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Triggers an immediate backup of the Marzban data and configuration. ```Shell marzban backup ``` -------------------------------- ### Update Marzban-node installation Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Updates the Marzban-node installation to the latest available version. ```Shell marzban-node update ``` -------------------------------- ### Install Specific Marzban Panel Version with SQLite Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs a specific version of the Marzban Panel (e.g., v0.5.2) on your server using the SQLite database. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --version v0.5.2 ``` -------------------------------- ### Install Marzban Node with Custom Name Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs the Marzban-node component on your server and assigns it a custom name (e.g., marzban-node2). ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install --name marzban-node2 ``` -------------------------------- ### Install Specific Marzban Panel Version with MySQL Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs a specific version of the Marzban Panel (e.g., v0.5.2) on your server using the MySQL database. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --database mysql --version v0.5.2 ``` -------------------------------- ### View all Marzban CLI commands Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Displays a list of all available commands for the Marzban CLI, providing an overview of its functionalities. ```Shell marzban help ``` -------------------------------- ### Install Developer Marzban Panel Version with MySQL Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs the developer version of the Marzban Panel on your server using the MySQL database. This version is constantly changing and under testing, recommended only for users with programming knowledge. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --database mysql --dev ``` -------------------------------- ### View all Marzban-node CLI commands Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Displays a list of all available commands for the Marzban-node CLI, providing an overview of its functionalities. ```Shell marzban-node help ``` -------------------------------- ### Install Marzban Node Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node This command installs the Marzban Node on your server. It fetches the installation script from the Gozargah GitHub repository and executes it to set up the node. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install ``` -------------------------------- ### Install Developer Marzban Panel Version with MariaDB Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs the developer version of the Marzban Panel on your server using the MariaDB database. This version is constantly changing and under testing, recommended only for users with programming knowledge. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --database mariadb --dev ``` -------------------------------- ### Access Marzban interactive CLI Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Provides interactive command-line access to the Marzban environment. ```Shell marzban cli ``` -------------------------------- ### Copy Environment Configuration File Source: https://gozargah.github.io/marzban/en/docs/introduction/installation This command creates a copy of the example environment configuration file (`.env.example`) to `.env`, which can then be customized for specific environment variables. ```bash cp .env.example .env ``` -------------------------------- ### Install Developer Marzban Panel Version with SQLite Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Installs the developer version of the Marzban Panel on your server using the SQLite database. This version is constantly changing and under testing, recommended only for users with programming knowledge. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --dev ``` -------------------------------- ### Clone Marzban Repository and Install Dependencies Source: https://gozargah.github.io/marzban/en/docs/introduction/installation This snippet clones the Marzban project from its GitHub repository, navigates into the project directory, and installs all required Python dependencies using pip from the `requirements.txt` file. ```bash git clone https://github.com/Gozargah/Marzban.git cd Marzban python3 -m pip install -r requirements.txt ``` -------------------------------- ### Install Marzban CLI and Auto-completion Source: https://gozargah.github.io/marzban/en/docs/introduction/installation These commands link the `marzban-cli.py` script to a system-wide executable path, make it executable, and install shell auto-completion for the Marzban command-line interface. ```bash sudo ln -s $(pwd)/marzban-cli.py /usr/bin/marzban-cli sudo chmod +x /usr/bin/marzban-cli marzban-cli completion install ``` -------------------------------- ### Install Docker using convenience script Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Downloads and executes the official Docker installation script, providing a quick and automated way to set up Docker Engine on a Linux system, which is required to run Marzban Node containers. ```bash curl -fsSL https://get.docker.com | sh ``` -------------------------------- ### Install Xray-core for Manual Marzban Installation Source: https://gozargah.github.io/marzban/en/docs/introduction/installation As a prerequisite for manual Marzban installation, this command installs Xray-core using the recommended Xray-install script. Xray is essential for Marzban's functionality. ```bash bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install ``` -------------------------------- ### Run Marzban Application Source: https://gozargah.github.io/marzban/en/docs/introduction/installation This command starts the Marzban application by executing its main Python script. By default, Marzban will listen for connections on port 8000. ```bash python3 main.py ``` -------------------------------- ### Update Marzban-node Xray core version Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Changes the Xray core version used by Marzban-node. By default, only the last five versions are displayed. To use a specific version, enter 'm' followed by the desired version, for example, 'v1.8.24'. ```Shell marzban-node core-update ``` -------------------------------- ### Update Marzban Xray core version Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Changes the Xray core version used by Marzban. By default, only the last 10 versions are displayed. To use a specific version, enter 'm' followed by the desired version, for example, 'v1.8.24'. ```Shell marzban core-update ``` -------------------------------- ### View Marzban service logs Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Displays the logs generated by the Marzban service, which can be used for debugging and monitoring. ```Shell marzban logs ``` -------------------------------- ### Marzban CLI: View `completion install` command help Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Displays the help message for the `marzban cli completion install` command, providing detailed information on its usage, options, and functionality. ```Shell marzban cli completion install --help ``` -------------------------------- ### View Marzban-node service logs Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Displays the logs generated by the Marzban-node service, which can be used for debugging and monitoring. ```Shell marzban-node logs ``` -------------------------------- ### Install Marzban Node with Custom Name Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Use this command to install Marzban Node on your server and assign a custom name to it, such as 'marzban-node2'. This helps in identifying and managing different nodes, especially in multi-node setups. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install --name marzban-node2 ``` -------------------------------- ### Uninstall Marzban from server Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Removes the Marzban installation and its associated files from the server. ```Shell marzban uninstall ``` -------------------------------- ### Uninstall Marzban-node from server Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Removes the Marzban-node installation and its associated files from the server. ```Shell marzban-node uninstall ``` -------------------------------- ### Restart Marzban Service Source: https://gozargah.github.io/marzban/en/docs/introduction/telegram-bot Command to restart the Marzban service after applying configuration changes in the `.env` file, ensuring that the new settings take effect and the Telegram bot is initialized with the updated variables. ```bash marzban restart ``` -------------------------------- ### Restart Marzban-node service Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Restarts the Marzban-node service, useful for applying configuration changes or resolving minor issues. ```Shell marzban-node restart ``` -------------------------------- ### Install and Activate Python Virtual Environment for Marzban Source: https://gozargah.github.io/marzban/en/docs/introduction/installation For developers or advanced users, it is recommended to install Marzban within a Python virtual environment. These commands install `virtualenv`, create a new virtual environment named `.venv`, and then activate it, isolating Marzban's dependencies. ```bash python3 -m pip install virtualenv python3 -m virtualenv .venv source .venv/bin/activate ``` -------------------------------- ### Marzban CLI: `completion install` command usage Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Demonstrates the basic syntax and option placement for the `marzban cli completion install` command, which is used to install shell completion scripts. ```Shell marzban cli completion install [OPTIONS] ``` -------------------------------- ### View Marzban-node service status Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Checks and displays the current operational status of the Marzban-node service. ```Shell marzban-node status ``` -------------------------------- ### View Marzban service status Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Checks and displays the current operational status of the Marzban service. ```Shell marzban status ``` -------------------------------- ### Restart Marzban service Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Restarts the Marzban service, useful for applying configuration changes or resolving minor issues. ```Shell marzban restart ``` -------------------------------- ### Create a Sudo Admin for Marzban Dashboard Source: https://gozargah.github.io/marzban/en/docs/introduction/installation After the quick installation, use this command to create an administrative user with sudo privileges for the Marzban dashboard. You will be prompted to set a username and password for login. ```bash marzban cli admin create --sudo ``` -------------------------------- ### Edit Marzban .env file Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Opens the .env environment variable file for Marzban for editing, allowing customization of settings. ```Shell marzban edit-env ``` -------------------------------- ### Build Marzban Database Source: https://gozargah.github.io/marzban/en/docs/introduction/installation This command uses Alembic to apply database migrations, setting up or upgrading the Marzban database schema to its latest version. ```bash alembic upgrade head ``` -------------------------------- ### Install Marzban Node Script Only Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node This command installs only the 'marzban-node' script on your server, without performing a full node installation. This allows for manual execution of node commands and custom configurations later. ```bash sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install-script ``` -------------------------------- ### Marzban CLI: Common Admin and User Management Examples Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Provides several examples of commonly used `marzban cli` commands for managing administrators and users, including creating sudo or non-sudo admins, deleting admins, changing panel passwords, and transferring user ownership. ```Shell marzban cli admin create --sudo ``` ```Shell marzban cli admin create ``` ```Shell marzban cli admin delete ``` ```Shell marzban cli admin update ``` ```Shell marzban cli user set-owner ``` -------------------------------- ### Full VLESS TCP Reality Inbound Configuration Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings A complete JSON configuration example for setting up a VLESS TCP Reality inbound in Xray-core, illustrating the structure for defining a secure proxy listener with detailed stream, security, and sniffing settings. ```json { "tag": "VLESS TCP REALITY", "listen": "0.0.0.0", "port": 443, "protocol": "vless", "settings": { "clients": [], "decryption": "none" }, "streamSettings": { "network": "tcp", "tcpSettings": {}, "security": "reality", "realitySettings": { "show": false, "dest": "google.com:443", "xver": 0, "serverNames": [ "example.com", "" ], "privateKey": "oNDJxLaAiXojgAcdW5gzwuQB_gMYL0DXfRnqswUKvTE", "publicKey": "oVRY8h7Njgw25j3CNhaJVMUys378tTvecrSRbrB3gyo", "shortIds": [ "2ebd6e17dec6a5d9" ] } }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } } ``` -------------------------------- ### Initialize and edit Marzban Node .env file Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Copies the example environment file `.env.example` to `.env` and then opens `.env` for editing. This allows users to configure Marzban Node environment variables externally, separating sensitive information from the `docker-compose.yml`. ```bash cp .env.example .env nano .env ``` -------------------------------- ### Install pip for Python 3 Source: https://gozargah.github.io/marzban/en/docs/introduction/installation If the `pip` command is not available on your system, this command downloads and installs pip for Python 3. Pip is required to manage Python packages, including Marzban's prerequisites. ```bash wget -qO- https://bootstrap.pypa.io/get-pip.py | python3 - ``` -------------------------------- ### Marzban Telegram Bot .env Configuration Variables Source: https://gozargah.github.io/marzban/en/docs/introduction/telegram-bot Defines the environment variables required in the `.env` file to configure the Marzban Telegram bot. These variables control the bot's token, administrator access, logging channel, default Vless flow settings, and proxy usage. ```APIDOC TELEGRAM_API_TOKEN: The token for the Telegram bot TELEGRAM_ADMIN_ID: The ID number of the admin in Telegram (if you need multiple admins to access the bot, specify their IDs separated by commas) TELEGRAM_LOGGER_CHANNEL_ID: The ID number of the channel for panel logs, if desired TELGRAM_DEFAULT_VLESS_FLOW: Sets the default flow for the Vless protocol in the Telegram bot TELEGRAM_PROXY_URL: Runs the bot through a proxy (if Telegram servers are blocked on your server) ``` -------------------------------- ### Update and install essential packages on Linux Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Updates the package list, upgrades installed packages, and installs `curl`, `socat`, and `git` on a Debian/Ubuntu-based system, which are necessary prerequisites for Marzban Node installation. ```bash apt-get update; apt-get upgrade -y; apt-get install curl socat git -y ``` -------------------------------- ### JSON Inbound 'listen' Property Example Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings Shows the 'listen' property, which specifies the IP address Xray-Core binds to for incoming connections. '0.0.0.0' configures the inbound to listen on all available network interfaces. ```json "listen": "0.0.0.0" ``` -------------------------------- ### Marzban Host Settings Variables and Usage Examples Source: https://gozargah.github.io/marzban/en/docs/introduction/host-settings This section details the available variables for customizing Marzban host settings fields such as Remark and Address. It provides a list of variables with their descriptions and examples demonstrating their output when used in the Remark field. ```APIDOC Variables: {SERVER_IP}: Master Server's IPv4 {USERNAME}: User's Username {DATA_USAGE}: User's Data Usage {DATA_LEFT}: User's Remaining Data {DATA_LIMIT}: User's Total Data Limit {DAYS_LEFT}: Remaining Days of the User's Subscription {TIME_LEFT}: Remaining Days, Hours, Minutes, Seconds of the User's Subscription {EXPIRE_DATE}: User's Expiration Date in English Calendar {JALALI_EXPIRE_DATE}: User's Expiration Date in Persian Calendar {STATUS_EMOJI}: User Status as an Emoji (✅,âŒ›ī¸,đŸĒĢ,❌,🔌) {PROTOCOL}: Configuration Protocols: Vless, Vmess ,Trojan, Shadowsocks, ... {TRANSPORT}: Transport Method for the Configuration: TCP, WS, gRPC, ... ``` ```APIDOC Examples: Remark field: 🚀 Server 1 ({USERNAME}) [{PROTOCOL} - {TRANSPORT}] Output: 🚀 Server 1 (user102) [VMess - ws] Remark field: Days Left: {DAYS_LEFT} Output: Dayy Left: 24 Remark field: Data Used: {DATA_LEFT}/{DATA_LIMIT} Output: Data Used: 16.5GB/30GB ``` -------------------------------- ### View Marzban Node Commands Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Execute this command to display a list of all available Marzban Node commands and their usage instructions. This is useful for exploring the script's functionalities and getting help on specific commands. ```bash marzban-node help ``` -------------------------------- ### Restart Marzban Service After Configuration Changes Source: https://gozargah.github.io/marzban/en/docs/introduction/installation After making modifications to the `.env` configuration file, use this command to restart the Marzban service. This ensures that all changes applied to the configuration take effect. ```bash marzban restart ``` -------------------------------- ### Stop Marzban service Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Shuts down and turns off the Marzban service. ```Shell marzban down ``` -------------------------------- ### Marzban Environment Variables Reference Source: https://gozargah.github.io/marzban/en/docs/introduction/configuration A comprehensive list of environment variables available for configuring the Marzban application, detailing their purpose, default values, and any specific notes or examples. ```APIDOC DISCORD_WEBHOOK_URL: Description: The Discord webhook address. ``` ```APIDOC CUSTOM_TEMPLATES_DIRECTORY: Default: app/templates Description: The directory for template files. ``` ```APIDOC CLASH_SUBSCRIPTION_TEMPLATE: Default: clash/default.yml Description: The template used to generate Clash configurations. (Example: https://github.com/Gozargah/Marzban/blob/master/app/templates/clash/default.yml) ``` ```APIDOC SUBSCRIPTION_PAGE_TEMPLATE: Default: subscription/index.html Description: The template used for the subscription information page. (Example: https://github.com/Gozargah/Marzban/blob/master/app/templates/subscription/index.html) ``` ```APIDOC HOME_PAGE_TEMPLATE: Default: home/index.html Description: The template used for the home page. (Example: https://github.com/Gozargah/Marzban/blob/master/app/templates/home/index.html) ``` ```APIDOC SUB_PROFILE_TITLE: Default: Subscription Description: The title of the subscription in the client. If the client supports this feature and the user does not select a title for the subscription, this value will be used as the subscription title. ``` ```APIDOC SUB_SUPPORT_URL: Description: The support contact address in the subscription link. (Example: "https://t.me/support") ``` ```APIDOC SUB_UPDATE_INTERVAL: Default: 12 Description: The time interval between automatic subscription updates (in hours). If the client supports this feature, the subscription will be updated every 12 hours. ``` ```APIDOC SQLALCHEMY_DATABASE_URL: Default: sqlite:///db.sqlite3 Description: The database address in SQLAlchemy format. See the available formats and drivers for the database address in the SQLAlchemy documentation (https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls). ``` ```APIDOC WEBHOOK_ADDRESS: Default: DEFAULT Description: The webhook address for notifications. ``` ```APIDOC WEBHOOK_SECRET: Default: DEFAULT Description: The secret key for webhook authentication. ``` ```APIDOC SUDO_USERNAME: Note: It is strongly recommended to use the Marzban CLI to create an admin and not use this variable. Description: You can set the username of the super admin from an environment variable. ``` ```APIDOC SUDO_PASSWORD: Note: It is strongly recommended to use the Marzban CLI to create an admin and not use this variable. Description: You can set the password of the super admin from an environment variable. ``` ```APIDOC DOCS: Default: false Description: Enable API documentation at /docs and /redoc. ``` ```APIDOC JWT_ACCESS_TOKEN_EXPIRE_MINUTES: Default: 1440 Description: The expiration time of the access token in minutes. Note: 0 means 'no expiration'. ``` ```APIDOC DEBUG: Default: false Description: Enable development mode. ``` ```APIDOC VITE_BASE_API: Default: /api/ Description: The API route prefix for use in the dashboard (front-end). ``` -------------------------------- ### Edit Marzban Configuration File with Nano Source: https://gozargah.github.io/marzban/en/docs/introduction/installation This command opens the Marzban `.env` configuration file located in `/opt/marzban/` using the `nano` text editor. This allows you to modify default settings and variables for your Marzban instance. ```bash nano /opt/marzban/.env ``` -------------------------------- ### Marzban CLI: Install shell completion for specific shell Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Installs shell completion for the `marzban cli` command, allowing users to specify the target shell from a list of supported options like bash, zsh, fish, powershell, or pwsh. ```Shell marzban cli completion install --shell [bash|zsh|fish|powershell|pwsh] ``` -------------------------------- ### Create Sudo Admin User with Marzban CLI Source: https://gozargah.github.io/marzban/en/docs/introduction/installation This command uses the `marzban-cli` tool to create a new superuser (admin) account for the Marzban application, granting it administrative privileges. ```bash marzban-cli admin create --sudo ``` -------------------------------- ### JSON VLESS Protocol 'settings' Property Example Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings Details the 'settings' property specific to the VLESS protocol, including the 'clients' array for authorized users and the 'decryption' method. An empty 'clients' array implies no specific client authentication is configured here, and 'none' for decryption. ```json "settings": { "clients": [], "decryption": "none" } ``` -------------------------------- ### Marzban Configuration: UVICORN_SSL_KEYFILE Source: https://gozargah.github.io/marzban/en/docs/introduction/configuration Specifies the file path to the SSL key for Marzban. An example path is given to illustrate the expected format. ```APIDOC UVICORN_SSL_KEYFILE Description: The path to the SSL key file. Example: /path/to/example.com/key.pem ``` -------------------------------- ### Start Marzban Node services with Docker Compose Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Executes the `docker compose up -d` command within the Marzban Node directory. This command starts the Marzban Node services defined in `docker-compose.yml` in detached mode, allowing them to run in the background. ```bash docker compose up -d ``` -------------------------------- ### Marzban Configuration: UVICORN_SSL_CERTFILE Source: https://gozargah.github.io/marzban/en/docs/introduction/configuration Defines the file path to the SSL certificate for Marzban. An example path is provided for clarity. ```APIDOC UVICORN_SSL_CERTFILE Description: The path to the SSL certificate file. Example: /path/to/example.com/fullchain.pem ``` -------------------------------- ### JSON Inbound 'tag' Property Example Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings Illustrates the 'tag' property, a string identifier used to uniquely name and distinguish specific inbound configurations within Xray-core, aiding in management and referencing. ```json "tag": "VLESS TCP REALITY" ``` -------------------------------- ### JSON Inbound 'streamSettings' Property Example Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings Explains the 'streamSettings' property, which configures the underlying network and security layers. It includes 'network' (e.g., 'tcp'), 'tcpSettings', 'security' (e.g., 'reality'), and detailed 'realitySettings' for advanced obfuscation and security features like 'dest', 'serverNames', and cryptographic keys. ```json "streamSettings": { "network": "tcp", "tcpSettings": {}, "security": "reality", "realitySettings": { "show": false, "dest": "google.com:443", "xver": 0, "serverNames": [ "example.com", "" ], "privateKey": "oNDJxLaAiXojgAcdW5gzwuQB_gMYL0DXfRnqswUKvTE", "publicKey": "oVRY8h7Njgw25j3CNhaJVMUys378tTvecrSRbrB3gyo", "shortIds": [ "2ebd6e17dec6a5d9" ] } } ``` -------------------------------- ### Configure Marzban Node docker-compose.yml to use .env file Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node This `docker-compose.yml` configuration example demonstrates how to load environment variables for the Marzban Node service from an external `.env` file. It simplifies the main compose file by externalizing configuration parameters. ```yml services: marzban-node: # build: . image: gozargah/marzban-node:latest restart: always network_mode: host env_file: .env volumes: - /var/lib/marzban-node:/var/lib/marzban-node ``` -------------------------------- ### Marzban CLI: Get User Subscription Proxies Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli This command retrieves the proxy configurations associated with a specific user's subscription. It is a subcommand of `marzban cli subscription` and provides direct access to proxy details. ```bash marzban cli subscription get-config ``` -------------------------------- ### Configure Marzban Node Docker Compose with Host Network Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node This configuration demonstrates how to set up two Marzban Node services in `docker-compose.yml` using `network_mode: host`. This allows the nodes to use all available ports directly from the host, but requires careful management to avoid port conflicts. It also includes the command to start the Docker containers. ```yml services: marzban-node-1: # build: . image: gozargah/marzban-node:latest restart: always network_mode: host environment: SERVICE_PORT: 2000 XRAY_API_PORT: 2001 SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert_1.pem" SERVICE_PROTOCOL: "rest" volumes: - /var/lib/marzban-node:/var/lib/marzban-node - /var/lib/marzban:/var/lib/marzban marzban-node-2: # build: . image: gozargah/marzban-node:latest restart: always network_mode: host environment: SERVICE_PORT: 3000 XRAY_API_PORT: 3001 SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert_2.pem" SERVICE_PROTOCOL: "rest" volumes: - /var/lib/marzban-node:/var/lib/marzban-node - /var/lib/marzban:/var/lib/marzban ``` ```bash docker compose up -d ``` -------------------------------- ### Configure Marzban Node docker-compose.yml for SSL and REST protocol Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node This `docker-compose.yml` configuration example sets up the Marzban Node service, enabling SSL client certificate authentication and the REST service protocol for improved stability. It defines the image, restart policy, network mode, environment variables for SSL certificate paths, and volume mapping for persistent data. ```yml services: marzban-node: # build: . image: gozargah/marzban-node:latest restart: always network_mode: host # env_file: .env environment: SSL_CERT_FILE: "/var/lib/marzban-node/ssl_cert.pem" SSL_KEY_FILE: "/var/lib/marzban-node/ssl_key.pem" SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert.pem" SERVICE_PROTOCOL: "rest" volumes: - /var/lib/marzban-node:/var/lib/marzban-node ``` -------------------------------- ### JSON Inbound 'protocol' Property Example Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings Highlights the 'protocol' property, which specifies the proxy protocol used for the inbound connection. 'vless' is a modern and secure protocol designed for efficient data transmission. ```json "protocol": "vless" ``` -------------------------------- ### Get User Proxies Configuration with Marzban CLI Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli This command retrieves the proxy configuration for a specified user. It supports various options for filtering by username, specifying output format (v2ray or clash), saving to a file, and encoding the output in base64. Use this to obtain user-specific proxy details. ```shell marzban cli subscription get-config [OPTIONS] ``` ```shell marzban cli subscription get-config -u TEXT ``` ```shell marzban cli subscription get-config -u TEXT -f [v2ray|clash] ``` ```shell marzban cli subscription get-config -u TEXT -f v2ray -o v2ray_config.json ``` ```shell marzban cli subscription get-config -u TEXT -f clash -o clash_config.yaml ``` ```shell marzban cli subscription get-config -u TEXT -f [v2ray|clash] --base64 ``` ```shell marzban cli subscription get-config --help ``` -------------------------------- ### Shadowsocks TCP Inbound Configuration Source: https://gozargah.github.io/marzban/en/docs/introduction/xray-inbounds Example JSON configuration for a Shadowsocks TCP inbound, listening on all interfaces on port 1080. It specifies the protocol as 'shadowsocks' and includes settings for clients and network types (tcp, udp). ```json { "tag": "Shadowsocks TCP", "listen": "0.0.0.0", "port": 1080, "protocol": "shadowsocks", "settings": { "clients": [], "network": "tcp,udp" } } ``` -------------------------------- ### JSON Inbound 'port' Property Example Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings Demonstrates the 'port' property, defining the network port on which Xray-Core listens for the inbound. Port 443 is commonly used for secure HTTPS traffic and is set here for the VLESS protocol. ```json "port": 443 ``` -------------------------------- ### Marzban CLI Completion Command Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Invokes the `completion` command within the Marzban CLI, typically used for shell auto-completion setup. ```Shell marzban cli completion ``` -------------------------------- ### VLESS TCP REALITY Configuration Source: https://gozargah.github.io/marzban/en/docs/introduction/xray-inbounds JSON configuration for a VLESS inbound proxy using the TCP network type with REALITY security. This setup listens on port 443 and directs traffic to a destination, requiring a private key and server names. ```json { "tag": "VLESS TCP REALITY", "listen": "0.0.0.0", "port": 443, "protocol": "vless", "settings": { "clients": [], "decryption": "none" }, "streamSettings": { "network": "tcp", "tcpSettings": {}, "security": "reality", "realitySettings": { "show": false, "dest": "google.com:443", "xver": 0, "serverNames": [ "example.com", "" ], "privateKey": "read the notes down below", "SpiderX": "/example", "shortIds": [ "read the notes down below" ] } }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } } ``` -------------------------------- ### VLESS XHTTP NoTLS Configuration Source: https://gozargah.github.io/marzban/en/docs/introduction/xray-inbounds Configures a VLESS inbound listener using the XHTTP network protocol without TLS encryption. This setup is suitable for scenarios where TLS is handled externally or not required, providing a basic HTTP-like transport. ```json { "tag": "VLESS XHTTP NoTLS", "listen": "0.0.0.0", "port": 443, "protocol": "vless", "settings": { "clients": [], "decryption": "none" }, "streamSettings": { "network": "xhttp", "xhttpSettings": { "mode": "auto" }, "security": "none" }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } } ``` -------------------------------- ### Example Marzban Webhook Request Format Source: https://gozargah.github.io/marzban/en/docs/introduction/webhook This snippet illustrates the typical structure of an HTTP POST request sent by Marzban as a webhook notification. It includes essential headers such as `x-webhook-secret` for signature verification and a JSON body containing event details like `username` and `action`. ```HTTP Request Headers: Host: 0.0.0.0:9000 User-Agent: python-requests/2.28.1 Accept-Encoding: gzip, deflate Accept: */* Connection: keep-alive x-webhook-secret: something-very-very-secret Content-Length: 107 Content-Type: application/json Body: {"username": "marzban_test_user", "action": "user_updated", "enqueued_at": 1680506457.636369, "tries": 0} ``` -------------------------------- ### Stop Marzban-node service Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-script Shuts down and turns off the Marzban-node service. ```Shell marzban-node down ``` -------------------------------- ### Configure Nginx for Marzban with SSL Source: https://gozargah.github.io/marzban/en/docs/introduction/installation This Nginx server block configuration sets up a reverse proxy for Marzban, listening on port 443 with SSL enabled. It includes certificate paths and proxies specific Marzban paths (dashboard, API, docs) to the backend application running on port 8000. ```nginx server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name marzban.example.com; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; location ~* /(dashboard|api|docs|redoc|openapi.json) { proxy_pass http://0.0.0.0:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ``` -------------------------------- ### Xray-Core Routing Rule to Block Specific Domains Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings This example illustrates how to use Xray-Core's `Routing` section to define rules for traffic management. It configures a rule to send requests for specified domains (e.g., `www.speedtest.net`, `fast.com`) to an outbound tagged `BLOCK`, which typically uses the `blackhole` protocol to prevent them from reaching their destination. ```json { "domain": [ "www.speedtest.net", "fast.com" ], "outboundTag": "BLOCK", "type": "field" }, ``` -------------------------------- ### View Marzban CLI Help Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Used to view the help documentation for the `marzban cli` command. This provides a quick reference for available options and sub-commands. ```Shell marzban cli --help ``` -------------------------------- ### Enable Marzban API Documentation Source: https://gozargah.github.io/marzban/en/docs/introduction/api To make Marzban's API documentation accessible, you must first enable it. This is done by setting the `DOCS` environment variable to `True`. ```env DOCS=True ``` -------------------------------- ### Create SSL client certificate file for Marzban Node Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Opens a new file at `/var/lib/marzban-node/ssl_client_cert.pem` using `nano`. This file is where the client certificate obtained from the Marzban Panel must be pasted to establish a secure connection. ```bash nano /var/lib/marzban-node/ssl_client_cert.pem ``` -------------------------------- ### Clone Marzban-node repository and create data directory Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Clones the Marzban-node Git repository from GitHub into the current user's home directory and creates a dedicated directory `/var/lib/marzban-node` for persistent node data and configurations. ```bash git clone https://github.com/Gozargah/Marzban-node mkdir /var/lib/marzban-node ``` -------------------------------- ### Marzban CLI: Subscription Command Overview Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli This section outlines the general usage and available options for the `marzban cli subscription` command, which serves as the primary entry point for managing user subscriptions. It acts as a parent command for more specific subscription operations. ```bash marzban cli subscription [OPTIONS] COMMAND [ARGS]... ``` ```bash marzban cli subscription --help ``` -------------------------------- ### Marzban Configuration: TELEGRAM_DEFAULT_VLESS_FLOW Source: https://gozargah.github.io/marzban/en/docs/introduction/configuration Sets the default flow for the Vless protocol when used with the Telegram bot. An example value 'xtls-rprx-vision' is provided. ```APIDOC TELEGRAM_DEFAULT_VLESS_FLOW Description: The default flow for the Vless protocol in the Telegram bot. Example: "xtls-rprx-vision" ``` -------------------------------- ### Marzban Core Settings: Basic DNS Configuration Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings This JSON configuration snippet illustrates how to set up DNS servers within the Marzban panel's 'Core Settings'. It includes a log level setting and defines Cloudflare's 1.1.1.1 as a primary DNS server, specifying an IPv4 query strategy. This section should be placed at the beginning of the core settings configuration. ```json { "log": { "loglevel": "info" }, "dns": { "servers": [ "1.1.1.1" ], "queryStrategy": "UseIPv4" }, "inbounds": [ ``` -------------------------------- ### Marzban Configuration: TELEGRAM_PROXY_URL Source: https://gozargah.github.io/marzban/en/docs/introduction/configuration Configures a proxy URL for the Telegram bot, useful if Telegram servers are blocked on the server. An example SOCKS5 proxy URL is shown. ```APIDOC TELEGRAM_PROXY_URL Description: To run the Telegram bot with a proxy (in case Telegram servers are blocked on your server). Example: "socks5://127.0.0.1:1080" ``` -------------------------------- ### Configure Multiple SSL Certificates for Inbounds Source: https://gozargah.github.io/marzban/en/docs/introduction/xray-inbounds JSON snippet demonstrating how to configure multiple SSL certificates within an inbound definition. Each certificate entry includes 'ocspStapling' duration, 'certificateFile' path, and 'keyFile' path for different domains. ```json "certificates": [ { "ocspStapling": 3600, "certificateFile": "/var/lib/marzban/certs/domain1.com/fullchain.pem", "keyFile": "/var/lib/marzban/certs/domain1.com/key.pem" }, { "ocspStapling": 3600, "certificateFile": "/var/lib/marzban/certs/domain2.com/fullchain.pem", "keyFile": "/var/lib/marzban/certs/domain2.com/key.pem" } ] ``` -------------------------------- ### Marzban CLI: Get User Subscription Link Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli This command fetches the unique subscription link for a specific user. It is a subcommand of `marzban cli subscription` and is used to provide users with their personal subscription access. ```bash marzban cli subscription get-link ``` -------------------------------- ### Marzban CLI: View `completion show` command help Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Displays the help message for the `marzban cli completion show` command, providing detailed information on its usage, options, and functionality. ```Shell marzban cli completion show --help ``` -------------------------------- ### Navigate to Marzban-node directory and open docker-compose.yml Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-node Changes the current directory to the cloned `~/Marzban-node` repository and opens the `docker-compose.yml` file for editing using the `nano` text editor, where critical service configurations are defined. ```bash cd ~/Marzban-node nano docker-compose.yml ``` -------------------------------- ### View Marzban CLI Admin Help Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Used to view the help documentation for the `admin` command. This provides detailed information on all available sub-commands and options for managing administrators. ```Shell marzban cli admin --help ``` -------------------------------- ### Configure Trojan GRPC TLS with External Certificate Files Source: https://gozargah.github.io/marzban/en/docs/introduction/xray-inbounds This JSON configuration sets up a Trojan listener on port 443 using gRPC and TLS. It requires external certificate and key files (`fullchain.pem`, `key.pem`) and specifies a gRPC `serviceName` as 'trojan'. Sniffing is enabled for HTTP, TLS, and QUIC traffic, and a `serverName` is required for TLS. ```json { "tag": "TROJAN GRPC TLS", "listen": "0.0.0.0", "port": 443, "protocol": "trojan", "settings": { "clients": [] }, "streamSettings": { "network": "grpc", "grpcSettings": { "serviceName": "trojan" }, "security": "tls", "tlsSettings": { "serverName": "SERVER_NAME", "certificates": [ { "ocspStapling": 3600, "certificateFile": "/var/lib/marzban/certs/fullchain.pem", "keyFile": "/var/lib/marzban/certs/key.pem" } ], "minVersion": "1.2", "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" } }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } } ``` -------------------------------- ### Download Marzban Subscription Page Template Source: https://gozargah.github.io/marzban/en/docs/introduction/subscription This command downloads the custom subscription page template from a GitHub repository and places it into the Marzban templates directory. It uses `wget` to fetch the `index.html` file, ensuring it's saved in `/var/lib/marzban/templates/subscription/`. ```bash sudo wget -N -P /var/lib/marzban/templates/subscription/ https://raw.githubusercontent.com/x0sina/marzban-sub/main/index.html ``` -------------------------------- ### Configure Xray Fallback Inbound Tag Environment Variable Source: https://gozargah.github.io/marzban/en/docs/introduction/xray-inbounds Example of setting the XRAY_FALLBACKS_INBOUND_TAG environment variable in the .env file to specify a fallback inbound tag for Xray. This variable needs to be uncommented and set to the desired inbound tag. ```env # XRAY_FALLBACKS_INBOUND_TAG = "INBOUND_X" ``` -------------------------------- ### Configure Trojan TCP TLS with External Certificate Files Source: https://gozargah.github.io/marzban/en/docs/introduction/xray-inbounds This JSON configuration defines a Trojan listener on port 443 using raw TCP and TLS. It uses external certificate and key files (`fullchain.pem`, `key.pem`) and sets `decryption` to 'none'. Sniffing is enabled for HTTP, TLS, and QUIC traffic, and a `serverName` is specified for TLS. ```json { "tag": "TROJAN TCP TLS", "listen": "0.0.0.0", "port": 443, "protocol": "trojan", "settings": { "clients": [], "decryption": "none" }, "streamSettings": { "network": "tcp", "security": "tls", "tlsSettings": { "serverName": "SERVER_NAME", "certificates": [ { "ocspStapling": 3600, "certificateFile": "/var/lib/marzban/certs/fullchain.pem", "keyFile": "/var/lib/marzban/certs/key.pem" } ], "minVersion": "1.2", "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" } }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } } ``` -------------------------------- ### Marzban CLI General Command Structure Source: https://gozargah.github.io/marzban/en/docs/introduction/marzban-cli Shows the general placement of options and commands for the `marzban cli` command. This structure applies to all main Marzban CLI operations. ```Shell marzban cli [OPTIONS] COMMAND [ARGS]... ``` -------------------------------- ### Configure Wildcard for Random SNI/Host Generation Source: https://gozargah.github.io/marzban/en/docs/introduction/host-settings Illustrates the use of the "*" character in SNI and Host fields to enable random subdomain generation. This technique helps distribute connections and requires a wildcard SSL certificate for the domain. ```Configuration *.example.com ``` ```Configuration access-*.example.com ``` -------------------------------- ### JSON Inbound 'sniffing' Property Example Source: https://gozargah.github.io/marzban/en/docs/introduction/core-settings Covers the 'sniffing' property, which controls traffic sniffing behavior. It includes 'enabled' to activate or deactivate sniffing and 'destOverride' to list protocols (like HTTP, TLS, QUIC) that should be excluded from sniffing. ```json "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.