Marzban Setup Guide

中文版

Complete guide for using the config manager with Marzban panel

← Back to Config Manager

Table of Contents

1. Understanding Marzban Configuration

What is Marzban?

Marzban is a web-based Xray management panel that separates configuration management from the core Xray settings.

Configuration File Locations

/opt/marzban/xray_config.json          # Xray core configuration
/opt/marzban/.env                      # Marzban environment variables
/var/lib/marzban/db.sqlite3            # Database (users, nodes)

Key Characteristics

2. Step-by-Step Instructions

1 Download Current Configuration

Method A: Via SSH (Recommended)

# Connect to your VPS
ssh user@your-vps-ip

# View configuration file
cat /opt/marzban/xray_config.json

# Download to local computer (run on local machine)
scp user@your-vps-ip:/opt/marzban/xray_config.json ~/Downloads/

Method B: Via Marzban Panel

  1. Login to Marzban web interface
  2. Go to System Settings
  3. Find Xray Configs
  4. Copy the configuration content to a local file

2 Use Config Manager to Modify

  1. Visit the config manager: https://config.167.icu
  2. Upload the downloaded xray_config.json file
  3. System automatically identifies it as Marzban configuration
  4. Click Modify Configuration button
  5. Download the modified configuration file

3 Backup Original Configuration

[Warning] Very Important! Always backup first!

# Connect to VPS
ssh user@your-vps-ip

# Backup original configuration
sudo cp /opt/marzban/xray_config.json /opt/marzban/xray_config.json.backup.$(date +%Y%m%d)

# Verify backup
ls -lh /opt/marzban/xray_config.json*

4 Upload New Configuration

# Upload from local to VPS (run on local machine)
scp ~/Downloads/config_modified.json user@your-vps-ip:/tmp/xray_config_new.json

# On VPS, replace configuration
ssh user@your-vps-ip
sudo mv /tmp/xray_config_new.json /opt/marzban/xray_config.json

# Set correct permissions
sudo chown marzban:marzban /opt/marzban/xray_config.json
sudo chmod 644 /opt/marzban/xray_config.json

5 Validate Configuration Syntax

# Validate JSON syntax before restart
cat /opt/marzban/xray_config.json | python3 -m json.tool > /dev/null

# If no output, the format is correct
# If there's an error, it will show the exact location

6 Restart Marzban Service

# Go to Marzban directory
cd /opt/marzban

# Restart service
sudo docker-compose restart

# Or restart only Xray core
sudo docker-compose exec marzban xray api restart

7 Check Service Status

# View container status
sudo docker-compose ps

# View logs (check for errors)
sudo docker-compose logs -f --tail=50

# Press Ctrl+C to exit log view

# Check if Xray is running properly
sudo docker-compose exec marzban ps aux | grep xray

8 Verify DNS Unlock Functionality

Test on client side:

# Test Instagram resolution
nslookup i.instagram.com

# Test Wikipedia resolution
nslookup en.wikipedia.org

# Access through proxy (make sure connected)
curl -I https://i.instagram.com
curl -I https://www.wikipedia.org

3. What Gets Modified

The config manager automatically adds the following to your configuration:

DNS Configuration

{
  "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 Rules

{
  "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"
      }
    ]
  }
}

4. Important Notes

[Warning] About Panel Modifications

If you later modify configuration through Marzban web interface, some versions may overwrite manual edits.

Solutions:

Good News:

5. Troubleshooting

Q1: After modification, users can't connect?

A: Immediately restore backup:

# Restore backup
sudo cp /opt/marzban/xray_config.json.backup.* /opt/marzban/xray_config.json

# Restart service
cd /opt/marzban
sudo docker-compose restart

Q2: How to confirm DNS unlock is working?

A: Test on VPS:

# Enter Marzban container
sudo docker-compose exec marzban bash

# Test DNS resolution
nslookup i.instagram.com 100.100.100.100

# Should return private IP (100.64.x.x)

Q3: Will configuration be lost after Marzban update?

A: No, but note:

  • Marzban updates usually don't affect xray_config.json
  • But it's recommended to backup before updating
  • Check configuration completeness after update

Q4: Do I need to modify each node separately?

A: No:

  • Xray configuration is global, shared by all nodes
  • Only need to modify xray_config.json once
  • All users created through Marzban will use this configuration

Quick Reference

Configuration File: /opt/marzban/xray_config.json

Restart Command: cd /opt/marzban && sudo docker-compose restart

View Logs: sudo docker-compose logs -f

Backup Command: sudo cp /opt/marzban/xray_config.json /opt/marzban/xray_config.json.backup.$(date +%Y%m%d)

Need help? Report an issue

← Back to Config Manager