Skip to content

Commit

Permalink
fix: translated latest node document
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtheted authored Nov 3, 2024
1 parent dfffe0e commit d163bb1
Showing 1 changed file with 150 additions and 39 deletions.
189 changes: 150 additions & 39 deletions marzban/en/docs/marzban-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,34 @@ title: Marzban Node

# Marzban Node

Using this guide, you can set up Marzban Node on one or more side servers and connect them to Marzban Panel so that you can use these servers in your configurations. Marzban Node allows you to distribute traffic load among different servers and also provides the ability to use servers with different locations.
Next, we will learn how to connect a node server to multiple Marzban Panels.
Marzban Node allows you to distribute traffic load among different servers and enables the use of servers with various locations. Using this guide, you can configure and set up the Marzban Node on one or more side servers and connect them to the Marzban panel so that you can utilize these servers in your configurations. You will also see how to connect a node to multiple Marzban panels down below.

## Setting up Marzban Node
## Setup Marzban Node (Script)

- Install Marzban-node on your server using this command.
```bash
sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install
```
- Install Marzban-node on your server using this command with custom name.
```bash
sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install --name marzban-node2
```
- Or you can only install this script (marzban-node command) on your server by using this command.
```bash
sudo bash -c "$(curl -sL https://github.com/Gozargah/Marzban-scripts/raw/master/marzban-node.sh)" @ install-script
```
::: tip Tip
- Use the following command to view all Marzban-node commands.
```bash
marzban-node help
```
:::

::: tip Tip
Marzban-node commands are thoroughly explained in [Marzban Script](https://gozargah.github.io/marzban/en/docs/marzban-script) document.
:::

## Setup Marzban Node (Manual)

- After logging into the node server terminal, first update the server with the following command and install necessary programs.
```bash
Expand All @@ -31,7 +55,15 @@ cd ~/Marzban-node
nano docker-compose.yml
```

- Remove the `#` sign behind `SSL_CLIENT_CERT_FILE` and align this line with the ones below. Then, you can delete the two lines related to `SSL_CERT_FILE` and `SSL_KEY_FILE`. After saving the changes, your file will be as follows:
::: tip Tip
The `docker-compose.yml` file is sensitive to indentation and spacing. You can use tools like [yamlchecker](https://yamlchecker.com) to validate your configuration.
:::

- Remove the `#` sign behind `SSL_CLIENT_CERT_FILE` and align this line with the ones below. Then, you can delete the two lines related to `SSL_CERT_FILE` and `SSL_KEY_FILE`.

- If you are using Marzban `v0.4.4` or any version above that, you can improve the stability of node connections by enabling the `REST` protocol. To do this, uncomment the corresponding line by removing the `#` at the beginning.

After saving the changes, your file will be as follows:

::: code-group
```yml [docker-compose.yml]
Expand All @@ -42,9 +74,41 @@ services:
restart: always
network_mode: host

# env_file: .env
environment:
SSL_CERT_FILE: "/var/lib/marzban-node/ssl_cert.pem"
SSL_KEY_FILE: "/var/lib/marzban-node/ssl_key.pem"
SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert.pem"
SERVICE_PROTOCOL: "rest"

volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
```
:::
::: tip Tip
If you intend to change the connection ports of the node to Marzban, you can add the two variables `XRAY_API_PORT` and `SERVICE_PORT` to the `environment` section in this file and specify your desired ports.
:::

::: details Using `.env` (Optional)
If you wish, you can set the Marzban Node environment variables from the `.env` file.

Create a copy of the `.env.example` file, open it for editing, and make the necessary changes in this file.
```bash
cp .env.example .env
nano .env
```

Then configure `docker-compose.yml` as it is down below.
::: code-group
```yml [docker-compose.yml]
services:
marzban-node:
# build: .
image: gozargah/marzban-node:latest
restart: always
network_mode: host
env_file: .env
volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
```
Expand Down Expand Up @@ -76,7 +140,8 @@ docker compose up -d
1. In the `Name` section, choose your desired name for the node.
2. Enter the IP address of the node in the `Address` section.
3. Leave default connection ports for the node including `Port` and `API Port` unchanged.
4. If you want your Marzban Node's host to be added for all inbounds as a new host, checkmark `Add this node as a new host for every inbound`.
4. In the `Usage Ratio` section, you can change the node consumption coefficient. The default value is `1`.
5. If you want your Marzban Node's host to be added for all inbounds as a new host, checkmark `Add this node as a new host for every inbound`.

::: tip Note
You can disable this checkmark and manually add the Node server IP only for necessary connections as a host in the `Host Settings` section.
Expand All @@ -88,7 +153,7 @@ You can disable this checkmark and manually add the Node server IP only for nece
If you have enabled a firewall on the Node server, you need to open ports for both panel connections and inbound ports in the Node server firewall.
:::

## Connecting Marzban Node to Multiple Panels
## Connect Marzban Node to Multiple Panels

If you need to connect a Node server to multiple Marzban Panels, you need to add a new node service in the `docker-compose.yml` file for each panel. This can be done in two ways.

Expand All @@ -105,7 +170,7 @@ In this case, you can use all available ports in your environment. Note that in

::: details Sample configuration of `docker-compose.yml`
::: code-group
```yml{11,27} [docker-compose.yml]
```yml{11,28} [docker-compose.yml]
services:
marzban-node-1:
# build: .
Expand All @@ -117,6 +182,7 @@ services:
SERVICE_PORT: 2000
XRAY_API_PORT: 2001
SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert_1.pem"
SERVICE_PROTOCOL: "rest"
volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
Expand All @@ -133,6 +199,7 @@ services:
SERVICE_PORT: 3000
XRAY_API_PORT: 3001
SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert_2.pem"
SERVICE_PROTOCOL: "rest"
volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
Expand All @@ -149,7 +216,7 @@ docker compose up -d
- The connection ports of the node for the panels and the specified ports for the inbounds will be as follows:

| Variable | Panel 1 | Panel 2 |
|----------------:|---------:|-------:|
|----------------|---------|-------|
| `Port` | 2000 | 3000 |
| `API Port` | 2001 | 3001 |
| `Inbound Ports` | As desired | As desired |
Expand All @@ -165,14 +232,15 @@ In this scenario, only specific ports are accessible and duplicate ports on the

::: details Sample configuration file `docker-compose.yml`
::: code-group
```yml{7,25} [docker-compose.yml]
```yml{7,26} [docker-compose.yml]
services:
marzban-node-1:
image: gozargah/marzban-node:latest
restart: always
environment:
SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert_1.pem"
SERVICE_PROTOCOL: "rest"
volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
Expand All @@ -191,6 +259,7 @@ services:
environment:
SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert_2.pem"
SERVICE_PROTOCOL: "rest"
volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
Expand All @@ -209,57 +278,99 @@ services:
- The connection ports of the node for the panels and the specified ports for the inbounds will be as follows:

| Variable | Panel 1 | Panel 2 |
|----------------:|-----------:|---------:|
|----------------|-----------|---------|
| `Port` | 2000 | 3000 |
| `API Port` | 2001 | 3001 |
| `Inbound Ports` | 2053 <br> 2054 | 2096 <br> 2097 |

::: tip Tip
If you intend to use Warp on the node server and have configured the `docker-compose.yml` file with the `Port Mapping` mode, you need to enable Warp with the `Xray` core. Warp will not work on the node server if you are using the `Wireguard` core.
:::

## Updating Marzban Node
## Update Marzban Node

- Enter Marzban Node directory.
```bash
cd Marzban-node
```

- Update Marzban Node using the following command.
- To update the Marzban Node, execute the following commands in order.
```bash
cd ~/Marzban-node
docker compose pull
docker compose down --remove-orphans; docker compose up -d
```

- Finally, restart Marzban Node using the following command.

## Additional Tips

::: tip Tip One
If you've made changes in the `docker-compose.yml` file, restart Marzban Node using the following command to apply the changes:
```bash
cd ~/Marzban-node
docker compose down --remove-orphans; docker compose up -d
```
To view the logs of the Marzban Node, use the following command.
```bash
cd ~/Marzban-node
docker compose logs -f
```
:::


## Additional Notes

::: tip Note 1
If you want to consider a separate inbound for each node for better node management, you need to add a new inbound in the `Core Settings` with unique `Tags` and `Ports` for each node.
::: tip Tip Two
If Marzban Node is not running the latest version of Xray and you wish to manually upgrade or downgrade it for any reason, you can do this by following the tutorial on [Changing Xray Core Version](https://gozargah.github.io/marzban/en/examples/change-xray-version).
:::

::: tip Note 2
If you intend to use Warp on the node server and you have configured the `docker-compose.yml` file through second method, you must enable Warp through `Xray core`. If you use Wireguard core, Warp will not work on the node server.
::: tip Tip Three
If you want to consider a separate inbound for each node for better node management, you need to add a new inbound in the `Core Settings` with unique `Tags` and `Ports` for each node.
:::

::: tip Note 3
::: tip Tip Four
If you plan to use TLS-configured settings, you must obtain a certificate for your domain on the node server, then move it to the master server and enter the path of certificate files in the inbound. Also, instead of multiple certificates for multiple subdomains, you can obtain a wildcard certificate for your main domain to cover all subdomains.
:::

::: tip Note 4
The `docker-compose.yml` file is sensitive to indentation and spacing. You can use tools like [yamlchecker](https://yamlchecker.com) to validate your configuration.
:::
## Configuration

You can see the list of Marzban Node environment variables in this section. You can set all of these variables in the `docker-compose.yml` file or the `.env` file related to the Marzban Node.

::: tip Note 5
If you've made changes in the `docker-compose.yml` file, restart Marzban Node using the following command to apply the changes:
```bash
cd ~/Marzban-node
docker compose down --remove-orphans; docker compose up -d
```
:::
::: details Environment Variables
### SERVICE_PORT
- Default value: `62050`

::: tip Note 6
If Marzban Node is not running the latest version of Xray and you wish to manually upgrade or downgrade it for any reason, you can do this by following the tutorial on [Changing Xray Core Version](https://gozargah.github.io/marzban/en/examples/change-xray-version).
:::
Service port for the Marzban Node

### XRAY_API_PORT
- Default value: `62051`

Port for the Xray API

### XRAY_EXECUTABLE_PATH
- Default value: `/usr/local/bin/xray`

Path to the Xray executable file

### XRAY_ASSETS_PATH
- Default value: `/usr/local/share/xray`

Path to the asset files folder for Xray (files `geoip.dat` and `geosite.dat`).

### SSL_CERT_FILE
- Default value: `/var/lib/marzban-node/ssl_cert.pem`

Path to the SSL certificate file

### SSL_KEY_FILE
- Default value: `/var/lib/marzban-node/ssl_key.pem`

Path to the SSL certificate key file

### SSL_CLIENT_CERT_FILE

Path to the user certificate file

### DEBUG
- Default value: `False`

Enable development mode

### SERVICE_PROTOCOL
- Default value: `rpyc`

Service protocol for the Marzban Node

:::

0 comments on commit d163bb1

Please sign in to comment.