Gozargah/Marzban 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 GNU Affero General Public License v3.0 许可证,目前获得 7.5k 个 Star、1.3k 次 Fork。
仓库全名
Gozargah/Marzban
README 摘要
Marzban Unified GUI Censorship Resistant Solution Powered by Xray English / فارسی / 简体中文 / Русский Table of Contents Overview Why using Marzban? Features Installation guide Configuration Documentation API Backup Telegram Bot Marzban CLI Marzban Node Webhook notifications Donation License Contributors Overview Marzban (the Persian word for "border guard" - pronounced /mærz'ban/) is a proxy management tool that…
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:
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:
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.
The template that will be used for generating clash configs (default: clash/default.yml)
SUBSCRIPTION_PAGE_TEMPLATE
The template used for generating subscription info page (default: subscription/index.html)
HOME_PAGE_TEMPLATE
Decoy page template (default: home/index.html)
TELEGRAM_API_TOKEN
Telegram bot API token (get token from @botfather)
TELEGRAM_ADMIN_ID
Numeric Telegram ID of admin (use @userinfobot to found your ID)
TELEGRAM_PROXY_URL
Run Telegram Bot over proxy
JWT_ACCESS_TOKEN_EXPIRE_MINUTES
Expire time for the Access Tokens in minutes, 0 considered as infinite (default: 1440)
DOCS
Whether API documents should be available on /docs and /redoc or not (default: False)
DEBUG
Debug mode for development (default: False)
WEBHOOK_ADDRESS
Webhook address to send notifications to. Webhook notifications will be sent if this value was set.
WEBHOOK_SECRET
Webhook secret will be sent with each request as x-webhook-secret in the header (default: None)
NUMBER_OF_RECURRENT_NOTIFICATIONS
How many times to retry if an error detected in sending a notification (default: 3)
RECURRENT_NOTIFICATIONS_TIMEOUT
Timeout between each retry if an error detected in sending a notification in seconds (default: 180)
NOTIFY_REACHED_USAGE_PERCENT
At which percentage of usage to send the warning notification (default: 80)
NOTIFY_DAYS_LEFT
When to send warning notifaction about expiration (default: 3)
USERS_AUTODELETE_DAYS
Delete expired (and optionally limited users) after this many days (Negative values disable this feature, default: -1)
USER_AUTODELETE_INCLUDE_LIMITED_ACCOUNTS
Whether to include limited accounts in the auto-delete feature (default: False)
USE_CUSTOM_JSON_DEFAULT
Enable custom JSON config for ALL supported clients (default: False)
USE_CUSTOM_JSON_FOR_V2RAYNG
Enable custom JSON config only for V2rayNG (default: False)
USE_CUSTOM_JSON_FOR_STREISAND
Enable custom JSON config only for Streisand (default: False)
USE_CUSTOM_JSON_FOR_V2RAYN
Enable 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:
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.
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.
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:
set TELEGRAM_API_TOKEN to your bot’s API Token
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
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.
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.
Thanks to the all contributors who have helped improve Marzban:
评论