Marzban

GozargahAGPL-3.0活跃维护

基于 Xray 的一体化抗审查代理管理面板,提供图形界面统一管理 VLESS、VMess、Trojan、Shadowsocks 等节点与用户,省去手写配置的麻烦。

Unified GUI Censorship Resistant Solution Powered by Xray

v0.8.4发布于 2025-01-09 16:11 UTC7,517star +6 / 7 天1,281fork同步于 2026-11-10 23:33 UTC

怎么上手

由 README 提炼,执行前请确认
sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install
marzban cli admin create --sudo
硬件要求按 README 说明

README 未说明显存或 GPU 要求;安装脚本面向 Linux 服务器,手动安装需 Python >= 3.8 并自行安装 Xray

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

基于 Xray 的代理账号管理面板,用 Web UI 统一管理大量代理用户与节点

基于 Xray 的一体化抗审查代理管理面板,提供图形界面统一管理 VLESS、VMess、Trojan、Shadowsocks 等节点与用户,省去手写配置的麻烦。

核心能力

  • 内置 Web UI 与完整 REST API 后端
  • 支持 Vmess、VLESS、Trojan、Shadowsocks 协议
  • 单用户多协议、单入站多用户、单端口多入站
  • 按流量与到期时间限制用户,支持周期性流量限额
  • 生成订阅链接与二维码,兼容 V2Ray、Clash、ClashMeta

容易踩的坑

出于安全考虑面板不能直接用 IP 访问,需先申请 SSL 证书并通过域名访问 https://YOUR_DOMAIN:8000/dashboard/;手动安装需先单独安装 Xray 并执行 alembic upgrade head 迁移数据库;默认监听 8000 端口,可用 UVICORN_HOST 和 UVICORN_PORT 修改

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.8.4
  1. v0.8.4最新正式版2025-01-09 · 2025-01-09 16:11 UTC

    v0.8.3...v0.8.4

    compare changes

    ❤️ Contributors

  2. v0.8.32025-01-09 · 2025-01-09 12:06 UTC
    查看更新说明

    v0.8.2...v0.8.3

    compare changes

    🩹 Fixes

    • Circular import in models (9e24dfb)
    • Circular import in jobs (5454c1c)

    ❤️ Contributors

  3. v0.8.22025-01-08 · 2025-01-08 21:33 UTC
    查看更新说明

    v0.8.1...v0.8.2

    compare changes

    🩹 Fixes

    • Send delete reports (#1573)
    • Clash tcp http config (#1574)
    • Json uuid encoder (#1582)

    ❤️ Contributors

  4. v0.8.12025-01-05 · 2025-01-05 14:28 UTC

    这个版本没有写更新说明。

  5. v0.8.02025-01-05 · 2025-01-05 11:20 UTC
    查看更新说明

    v0.7.0...v0.8.0

    compare changes

    🚀 Enhancements

    • webhook: Send multiple webhook for user usages (1da862c)
    • tgbot: Add create bulk user (e985dc0)
    • tgbot: Add Bulk User From Template (d21689d)
    • xray-core: Add XHTTP an alias of SplitHTTP (#1417)
    • admin: Admin usage field (#1428)
    • api: Add endpoints for disable and activate all users (#1442)
    • xray-core: Add support for xhttp new variables (#1447)
    • api: Add counter for all user status to /system (#1445)
    • admin: Admin usage log (#1448)
    • Add migration to correct last_status_change for expired users (#1187)
    • Add random selection from reality shortIds (#1490)
    • db: Increase length of the host and sni columns (#1505)
    • Add use sni as host (#1516)
    • cli: Add users usage to admin list command (#1530)
    • xray: Add hex type support for noise (f41c648)

    🩹 Fixes

    • clash: Http transport (d7426a3)
    • frontend: Misspelled duplicate (c9ff289)
    • Add 401 for (03991e3)
    • Default value for NOTIFY_REACHED_USAGE_PERCENT and NOTIFY_DAYS_LEFT (262a33f)
    • jobs: USAGES_INTERVAL env variables (efa7fd2)
    • clash: Wrong smux option (f2c52cf)
    • clash: early data not supported by httpupgrade (633f92c)
    • subscription: Only save vpn app user-agents (#1422)
    • Reset usage bug (#1424)
    • admin: Users_usage crash on migrations (#1429)
    • jobs: AttributeError: 'list' object has no attribute 'items' (#1436)
    • Make on_hold fields None when user is activate (#1444)
    • Syntax warnings in python 3.12 (771d7bc)
    • db: Error when counting online users in mysql (#1453)
    • tgbot: None type error when sending logs to channel (#1465)
    • Incorrect status codes on the subscription page (#1463)
    • Multiple heads error (#1474)
    • Path and host not sended in ws (#1475)
    • Xhttp extra in v2ray links (#1476)
    • api: Decorator variable must match the function argument (#1483)
    • Added Marzban's installation commands for MySQL & MariaDB and backup-service commands (#1486)
    • Added a note regarding SSL & Documentation (#1489)
    • admin: Record admin usage (#1496)
    • admin: Record admin usage (#1498)
    • Error when sending reports for autodelete (#1512)
    • cli: Error when get reseted usage (#1520)
    • Float node coefficient (#1524)
    • Delete deprecates and optimize (#1528)
    • Float bug when creating users and showing float data (#1541)
    • Use for header in 401 response (5a855f2)
    • Remove single quotes from error messages (a44327f)

    ❤️ Contributors

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Table of Contents

    Overview

    Marzban (the Persian word for "border guard" - pronounced /mærz'ban/) is a proxy management tool that provides a simple and easy-to-use user interface for managing hundreds of proxy accounts powered by Xray-core and built using Python and Reactjs.

    Why using Marzban?

    Marzban is user-friendly, feature-rich and reliable. It lets you to create different proxies for your users without any complicated configuration. Using its built-in web UI, you are able to monitor, modify and limit users.

    Features

    • Built-in Web UI
    • Fully REST API backend
    • Multiple Nodes support (for infrastructure distribution & scalability)
    • Supports protocols Vmess, VLESS, Trojan and Shadowsocks
    • Multi-protocol for a single user
    • Multi-user on a single inbound
    • Multi-inbound on a single port (fallbacks support)
    • Traffic and expiry date limitations
    • Periodic traffic limit (e.g. daily, weekly, etc.)
    • Subscription link compatible with V2ray (such as V2RayNG, SingBox, Nekoray, etc.), Clash and ClashMeta
    • Automated Share link and QRcode generator
    • System monitoring and traffic statistics
    • Customizable xray configuration
    • TLS and REALITY support
    • Integrated Telegram Bot
    • Integrated Command Line Interface (CLI)
    • Multi-language
    • Multi-admin support (WIP)

    Installation guide

    Run the following command to install Marzban with SQLite database:

    sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install
    

    Run the following command to install Marzban with MySQL database:

    sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --database mysql
    

    Run the following command to install Marzban with MariaDB database:

    sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install --database mariadb
    

    Once the installation is complete:

    • You will see the logs that you can stop watching them by closing the terminal or pressing Ctrl+C
    • The Marzban files will be located at /opt/marzban
    • The configuration file can be found at /opt/marzban/.env (refer to configurations section to see variables)
    • The data files will be placed at /var/lib/marzban
    • For security reasons, the Marzban dashboard is not accessible via IP address. Therefore, you must obtain SSL certificate and access your Marzban dashboard by opening a web browser and navigating to https://YOUR_DOMAIN:8000/dashboard/ (replace YOUR_DOMAIN with your actual domain)
    • You can also use SSH port forwarding to access the Marzban dashboard locally without a domain. Replace user@serverip with your actual SSH username and server IP and Run the command below:
    ssh -L 8000:localhost:8000 user@serverip
    

    Finally, you can enter the following link in your browser to access your Marzban dashboard:

    http://localhost:8000/dashboard/

    You will lose access to the dashboard as soon as you close the SSH terminal. Therefore, this method is recommended only for testing purposes.

    Next, you need to create a sudo admin for logging into the Marzban dashboard by the following command

    marzban cli admin create --sudo
    

    That's it! You can login to your dashboard using these credentials

    To see the help message of the Marzban script, run the following command

    marzban --help
    

    If you are eager to run the project using the source code, check the section below

    Install xray on your machine

    You can install it using Xray-install

    bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
    

    Clone this project and install the dependencies (you need Python >= 3.8)

    git clone https://github.com/Gozargah/Marzban.git
    cd Marzban
    wget -qO- https://bootstrap.pypa.io/get-pip.py | python3 -
    python3 -m pip install -r requirements.txt
    

    Alternatively, to have an isolated environment you can use Python Virtualenv

    Then run the following command to run the database migration scripts

    alembic upgrade head
    

    If you want to use marzban-cli, you should link it to a file in your $PATH, make it executable, and install the auto-completion:

    sudo ln -s $(pwd)/marzban-cli.py /usr/bin/marzban-cli
    sudo chmod +x /usr/bin/marzban-cli
    marzban-cli completion install
    

    Now it's time to configuration

    Make a copy of .env.example file, take a look and edit it using a text editor like nano.

    You probably like to modify the admin credentials.

    cp .env.example .env
    nano .env
    

    Check configurations section for more information

    Eventually, launch the application using command below

    python3 main.py
    

    To launch with linux systemctl (copy marzban.service file to /var/lib/marzban/marzban.service)

    systemctl enable /var/lib/marzban/marzban.service
    systemctl start marzban
    

    To use with nginx

    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name  example.com;
    
        ssl_certificate      /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key  /etc/letsencrypt/live/example.com/privkey.pem;
    
        location ~* /(dashboard|statics|sub|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 ws-path: /
        # client ws-path: /marzban/me/2087
        #
        # All traffic is proxed through port 443, and send to the xray port(2087, 2088 etc.).
        # The '/marzban' in location regex path can changed any characters by yourself.
        #
        # /${path}/${username}/${xray-port}
        location ~* /marzban/.+/(.+)$ {
            proxy_redirect off;
            proxy_pass http://127.0.0.1:$1/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
    

    or

    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 / {
            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;
        }
    }
    

    By default the app will be run on http://localhost:8000/dashboard. You can configure it using changing the UVICORN_HOST and UVICORN_PORT environment variables.

    Configuration

    You can set settings below using environment variables or placing them in .env file.

    VariableDescription
    SUDO_USERNAMESuperuser's username
    SUDO_PASSWORDSuperuser's password
    SQLALCHEMY_DATABASE_URLDatabase URL (SQLAlchemy's docs)
    UVICORN_HOSTBind application to this host (default: 0.0.0.0)
    UVICORN_PORTBind application to this port (default: 8000)
    UVICORN_UDSBind application to a UNIX domain socket
    UVICORN_SSL_CERTFILESSL certificate file to have application on https
    UVICORN_SSL_KEYFILESSL key file to have application on https
    UVICORN_SSL_CA_TYPEType of authority SSL certificate. Use private for testing self-signed CA (default: public)
    XRAY_JSONPath of Xray's json config file (default: xray_config.json)
    XRAY_EXECUTABLE_PATHPath of Xray binary (default: /usr/local/bin/xray)
    XRAY_ASSETS_PATHPath of Xray assets (default: /usr/local/share/xray)
    XRAY_SUBSCRIPTION_URL_PREFIXPrefix of subscription URLs
    XRAY_FALLBACKS_INBOUND_TAGTag of the inbound that includes fallbacks, needed in the case you're using fallbacks
    XRAY_EXCLUDE_INBOUND_TAGSTags of the inbounds that shouldn't be managed and included in links by application
    CUSTOM_TEMPLATES_DIRECTORYCustomized templates directory (default: app/templates)
    CLASH_SUBSCRIPTION_TEMPLATEThe template that will be used for generating clash configs (default: clash/default.yml)
    SUBSCRIPTION_PAGE_TEMPLATEThe template used for generating subscription info page (default: subscription/index.html)
    HOME_PAGE_TEMPLATEDecoy page template (default: home/index.html)
    TELEGRAM_API_TOKENTelegram bot API token (get token from @botfather)
    TELEGRAM_ADMIN_IDNumeric Telegram ID of admin (use @userinfobot to found your ID)
    TELEGRAM_PROXY_URLRun Telegram Bot over proxy
    JWT_ACCESS_TOKEN_EXPIRE_MINUTESExpire time for the Access Tokens in minutes, 0 considered as infinite (default: 1440)
    DOCSWhether API documents should be available on /docs and /redoc or not (default: False)
    DEBUGDebug mode for development (default: False)
    WEBHOOK_ADDRESSWebhook address to send notifications to. Webhook notifications will be sent if this value was set.
    WEBHOOK_SECRETWebhook secret will be sent with each request as x-webhook-secret in the header (default: None)
    NUMBER_OF_RECURRENT_NOTIFICATIONSHow many times to retry if an error detected in sending a notification (default: 3)
    RECURRENT_NOTIFICATIONS_TIMEOUTTimeout between each retry if an error detected in sending a notification in seconds (default: 180)
    NOTIFY_REACHED_USAGE_PERCENTAt which percentage of usage to send the warning notification (default: 80)
    NOTIFY_DAYS_LEFTWhen to send warning notifaction about expiration (default: 3)
    USERS_AUTODELETE_DAYSDelete expired (and optionally limited users) after this many days (Negative values disable this feature, default: -1)
    USER_AUTODELETE_INCLUDE_LIMITED_ACCOUNTSWhether to include limited accounts in the auto-delete feature (default: False)
    USE_CUSTOM_JSON_DEFAULTEnable custom JSON config for ALL supported clients (default: False)
    USE_CUSTOM_JSON_FOR_V2RAYNGEnable custom JSON config only for V2rayNG (default: False)
    USE_CUSTOM_JSON_FOR_STREISANDEnable custom JSON config only for Streisand (default: False)
    USE_CUSTOM_JSON_FOR_V2RAYNEnable custom JSON config only for V2rayN (default: False)

    Documentation

    The Marzban Documentation provides all the essential guides to get you started, available in three languages: Farsi, English, and Russian. This documentation requires significant effort to cover all aspects of the project comprehensively. We welcome and appreciate your contributions to help us improve it. You can contribute on this GitHub repository.

    API

    Marzban provides a REST API that enables developers to interact with Marzban services programmatically. To view the API documentation in Swagger UI or ReDoc, set the configuration variable DOCS=True and navigate to the /docs and /redoc.

    Backup

    It's always a good idea to backup your Marzban files regularly to prevent data loss in case of system failures or accidental deletion. Here are the steps to backup Marzban:

    1. By default, all Marzban important files are saved in /var/lib/marzban (Docker versions). Copy the entire /var/lib/marzban directory to a backup location of your choice, such as an external hard drive or cloud storage.
    2. Additionally, make sure to backup your env file, which contains your configuration variables, and also, your Xray config file. If you installed Marzban using marzban-scripts (recommended installation approach), the env and other configurations should be inside /opt/marzban/ directory.

    Marzban's backup service efficiently zips all necessary files and sends them to your specified Telegram bot. It supports SQLite, MySQL, and MariaDB databases. One of its key features is automation, allowing you to schedule backups every hour. There are no limitations concerning Telegram's upload limits for bots; if a file exceeds the limit, it will be split and sent in multiple parts. Additionally, you can initiate an immediate backup at any time.

    Install the Latest Version of Marzban Command:

    sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install-script
    

    Setup the Backup Service:

    marzban backup-service
    

    Get an Immediate Backup:

    marzban backup
    

    By following these steps, you can ensure that you have a backup of all your Marzban files and data, as well as your configuration variables and Xray configuration, in case you need to restore them in the future. Remember to update your backups regularly to keep them up-to-date.

    Telegram Bot

    Marzban comes with an integrated Telegram bot that can handle server management, user creation and removal, and send notifications. This bot can be easily enabled by following a few simple steps, and it provides a convenient way to interact with Marzban without having to log in to the server every time.

    To enable Telegram Bot:

    1. set TELEGRAM_API_TOKEN to your bot's API Token
    2. set TELEGRAM_ADMIN_ID to your Telegram account's numeric ID, you can get your ID from @userinfobot

    Marzban CLI

    Marzban comes with an integrated CLI named marzban-cli which allows administrators to have direct interaction with it.

    If you've installed Marzban using easy install script, you can access the cli commands by running

    marzban cli [OPTIONS] COMMAND [ARGS]...
    

    For more information, You can read Marzban CLI's documentation.

    Marzban Node

    The Marzban project introduces the Marzban-node, which revolutionizes infrastructure distribution. With Marzban-node, you can distribute your infrastructure across multiple locations, unlocking benefits such as redundancy, high availability, scalability, flexibility. Marzban-node empowers users to connect to different servers, offering them the flexibility to choose and connect to multiple servers instead of being limited to only one server. For more detailed information and installation instructions, please refer to the Marzban-node official documentation

    Webhook notifications

    You can set a webhook address and Marzban will send the notifications to that address.

    the requests will be sent as a post request to the adress provided by WEBHOOK_ADDRESS with WEBHOOK_SECRET as x-webhook-secret in the headers.

    Example request sent from Marzban:

    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}
    

    Different action typs are: user_created, user_updated, user_deleted, user_limited, user_expired, user_disabled, user_enabled

    Donation

    If you found Marzban useful and would like to support its development, you can make a donation in one of the following crypto networks:

    • TRON network (TRC20): TX8kJoDcowQPBFTYHAJR36GyoUKP1Xwzkb
    • ETH, BNB, MATIC network (ERC20, BEP20): 0xFdc9ad32454FA4fc4733270FCc12ddBFb68b83F7
    • Bitcoin network: bc1qpys2nefgsjjgae3g3gqy9crsv3h3rm96tlkz0v
    • Dogecoin network: DJAocBAu8y6LwhDKUktLAyzV8xyoFeHH6R
    • TON network: EQAVf-7hAXHlF-jmrKE44oBwN7HGQFVBLAtrOsev5K4qR4P8

    Thank you for your support!

    License

    Made in [Unknown!] and Published under AGPL-3.0.

    Contributors

    We ❤️‍🔥 contributors! If you'd like to contribute, please check out our Contributing Guidelines and feel free to submit a pull request or open an issue. We also welcome you to join our Telegram group for either support or contributing guidance.

    Check open issues to help the progress of this project.