Marzban是一个基于Web的Xray管理面板,它将配置管理与Xray核心设置分离。
/opt/marzban/xray_config.json # Xray核心配置
/opt/marzban/.env # Marzban环境变量
/var/lib/marzban/db.sqlite3 # 数据库(用户、节点等)
方法A:通过SSH下载(推荐)
# 连接到VPS
ssh user@your-vps-ip
# 查看配置文件
cat /opt/marzban/xray_config.json
# 复制到本地(在本地电脑执行)
scp user@your-vps-ip:/opt/marzban/xray_config.json ~/Downloads/
方法B:通过Marzban面板导出
xray_config.json文件[警告] 非常重要!必须先备份!
# 连接到VPS
ssh user@your-vps-ip
# 备份原配置
sudo cp /opt/marzban/xray_config.json /opt/marzban/xray_config.json.backup.$(date +%Y%m%d)
# 验证备份
ls -lh /opt/marzban/xray_config.json*
# 从本地上传到VPS(在本地执行)
scp ~/Downloads/config_modified.json user@your-vps-ip:/tmp/xray_config_new.json
# 在VPS上替换配置
ssh user@your-vps-ip
sudo mv /tmp/xray_config_new.json /opt/marzban/xray_config.json
# 设置正确的权限
sudo chown marzban:marzban /opt/marzban/xray_config.json
sudo chmod 644 /opt/marzban/xray_config.json
# 在重启之前验证JSON格式
cat /opt/marzban/xray_config.json | python3 -m json.tool > /dev/null
# 如果没有输出,说明格式正确
# 如果有错误,会显示具体位置
# 进入Marzban目录
cd /opt/marzban
# 重启服务
sudo docker-compose restart
# 或者只重启Xray核心
sudo docker-compose exec marzban xray api restart
# 查看容器状态
sudo docker-compose ps
# 查看日志(检查是否有错误)
sudo docker-compose logs -f --tail=50
# 按Ctrl+C退出日志查看
# 检查Xray是否正常运行
sudo docker-compose exec marzban ps aux | grep xray
在客户端测试:
# 测试Instagram解析
nslookup i.instagram.com
# 测试Wikipedia解析
nslookup en.wikipedia.org
# 通过代理访问(确保已连接)
curl -I https://i.instagram.com
curl -I https://www.wikipedia.org
配置管理器会自动添加以下内容到您的配置中:
{
"dns": {
"servers": [
{
"address": "100.100.100.100",
"port": 53,
"domains": [
"full:i.instagram.com",
"full:www.instagram.com",
"domain:wikipedia.org"
],
"expectIPs": ["geoip:private"],
"skipFallback": true
},
"8.8.8.8",
"1.1.1.1"
],
"queryStrategy": "UseIP"
}
}
{
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"domain": [
"full:i.instagram.com",
"full:www.instagram.com",
"domain:wikipedia.org"
],
"outboundTag": "direct"
},
{
"type": "field",
"ip": ["100.64.0.0/10"],
"outboundTag": "direct"
}
]
}
}
如果您之后通过Marzban Web界面修改配置,某些版本可能会覆盖手动编辑的内容。
A: 立即恢复备份:
# 恢复备份
sudo cp /opt/marzban/xray_config.json.backup.* /opt/marzban/xray_config.json
# 重启服务
cd /opt/marzban
sudo docker-compose restart
A: 在VPS上测试:
# 进入Marzban容器
sudo docker-compose exec marzban bash
# 测试DNS解析
nslookup i.instagram.com 100.100.100.100
# 应该返回内网IP(100.64.x.x)
A: 不会,但需注意:
xray_config.jsonA: 不需要:
xray_config.json配置文件:/opt/marzban/xray_config.json
重启命令:cd /opt/marzban && sudo docker-compose restart
查看日志:sudo docker-compose logs -f
备份命令:sudo cp /opt/marzban/xray_config.json /opt/marzban/xray_config.json.backup.$(date +%Y%m%d)