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.
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.
Run the following command
sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban.sh)" @ install
Once the installation is complete:
Ctrl+C
/opt/marzban
/opt/marzban/.env
(refer to configurations section to see variables)/var/lib/marzban
http://YOUR_SERVER_IP:8000/dashboard/
(replace YOUR_SERVER_IP with the actual IP address of your server)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
<details markdown="1"> <summary><h3>Manual install (advanced)</h3></summary>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|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.
You can set settings below using environment variables or placing them in
.env
file.
Variable | Description |
---|---|
SUDO_USERNAME | Superuser's username |
SUDO_PASSWORD | Superuser's password |
SQLALCHEMY_DATABASE_URL | Database URL (SQLAlchemy's docs) |
UVICORN_HOST | Bind application to this host (default: 0.0.0.0 ) |
UVICORN_PORT | Bind application to this port (default: 8000 ) |
UVICORN_UDS | Bind application to a UNIX domain socket |
UVICORN_SSL_CERTFILE | SSL certificate file to have application on https |
UVICORN_SSL_KEYFILE | SSL key file to have application on https |
XRAY_JSON | Path of Xray's json config file (default: xray_config.json ) |
XRAY_EXECUTABLE_PATH | Path of Xray binary (default: /usr/local/bin/xray ) |
XRAY_ASSETS_PATH | Path of Xray assets (default: /usr/local/share/xray ) |
XRAY_SUBSCRIPTION_URL_PREFIX | Prefix of subscription URLs |
XRAY_FALLBACKS_INBOUND_TAG | Tag of the inbound that includes fallbacks, needed in the case you're using fallbacks |
XRAY_EXCLUDE_INBOUND_TAGS | Tags of the inbounds that shouldn't be managed and included in links by application |
CUSTOM_TEMPLATES_DIRECTORY | Customized templates directory (default: app/templates ) |
CLASH_SUBSCRIPTION_TEMPLATE | 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 | Weather 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 ) |
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
.
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:
/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./opt/marzban/
directory.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.
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:
TELEGRAM_API_TOKEN
to your bot's API TokenTELEGRAM_ADMIN_ID
to your Telegram account's numeric ID, you can get your ID from @userinfobotMarzban 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.
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
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,
字节跳动发布的AI编程神器IDE
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码 自动完成功能,是提升开发效率的理想工具。
全能AI智能助手,随时解答生活与工作的多样问题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动 ,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等 等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写 作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。
AI助力,做PPT更简单!
咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务 。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。
选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。
专业的AI公文写作平台,公文写作神器
AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。
OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。
openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。