Skip to content

Commit

Permalink
Update marzban-node.md
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtheted authored May 5, 2024
1 parent 1320748 commit dfd60ad
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions marzban/en/docs/marzban-node.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Marzban Node
---

# Marzban Node

With the help of this tutorial, you can set up Marzban Node on one or more side servers and connect them to the 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.
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.

## Setting up Marzban Node

Expand All @@ -24,13 +25,13 @@ git clone https://github.com/Gozargah/Marzban-node
mkdir /var/lib/marzban-node
```

- To establish a secure connection between the node and the border panel, changes need to be made in the `docker-compose.yml` file. So, navigate to the main folder of Border Patrol Node and open this file for editing.
- To establish a secure connection between Marzban Node and Marzban Panel, you need to make certain changes in the `docker-compose.yml` file. So, navigate to the main directory of Marzban Node and open this file for editing.
```bash
cd ~/Marzban-node
nano docker-compose.yml
```

- Remove the `#` sign at the beginngog of the phrase `SSL_CLIENT_CERT_FILE` and align this line with the one below. After saving the changes, your file content will be as follows:
- 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:

::: code-group
```yml [docker-compose.yml]
Expand All @@ -43,43 +44,42 @@ services:

environment:
SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert.pem"
SSL_CERT_FILE: "/var/lib/marzban-node/ssl_cert.pem"
SSL_KEY_FILE: "/var/lib/marzban-node/ssl_key.pem"

volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
```
:::
- Now go to the `Node Settings` section through the menu in your panel.
Then, by clicking on `Add New Mazrban Node`, add a new node.
- Now go to the `Node Settings` section in your Marzban Panel.
Then, click on `Add New Mazrban Node`, and add a new node.

- By clicking on the `Show Certificate` button, you will see the certificate required for connecting to the node. Copy this certificate and continue following the steps from the terminal of your node server.
- If you click on `Show Certificate` button, you will see the certificate required for node connection. Copy this certificate and continue following the steps from the terminal of your node server.

<img src="https://github.com/mdjvd/gozargah.github.io/assets/116950557/bee4bbf0-f811-4b20-af28-adee270b469d"
style="display:block;float:none;margin-left:auto;margin-right:auto;width:47%">
<br>

- Create a certificate file with the following command and paste the copied content inside it.
- Create the certificate file with the following command and paste it there.
```bash
nano /var/lib/marzban-node/ssl_client_cert.pem
```

- Then run the command.
- Then run the command in Marzban Node directory.
```bash
docker compose up -d
```


- Return to the Marzban Panel and complete the different sections as follows:

1. In the `Name` section, choose a desired name for the node.
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 node's border host to be added for all inbound connections as a new host, checkmark 'Add this node as a new host for every inbound'.
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`.

::: tip Note
You can disable this checkbox and add the Node server IP only for necessary connections as a host in the `Host Settings` section.
You can disable this checkmark and manually add the Node server IP only for necessary connections as a host in the `Host Settings` section.
:::

- Finally, click on `Add Node` to add the node. Now the node is ready to use. You can use the Node server IP for desired connections by managing your hosts in the `Host Settings` section.
Expand All @@ -90,16 +90,16 @@ If you have enabled a firewall on the Node server, you need to open ports for bo

## Connecting Marzban Node to Multiple Panels

If you need to connect a Node server to multiple Border 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.
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.

::: tip Note
In both configuration options, you can modify port settings used in sample `docker-compose.yml` files according to your needs. Additionally, you can add as many node services as required in this file.
In both configuration options, you can modify port settings used in sample `docker-compose.yml` files to suit your needs. Additionally, you can add as many node services as required in this file.

:::

### First case: Using Host Network
### First Method: Using Host Network

In this case, you have the ability to use all available ports in your environment. Note that in this situation, all ports used by Xray-Core panels will be listened on by the node server. This means that if there is a duplicate port in the Xray core panels, there may be disruptions in node connections or configurations. To avoid this issue, you can configure your settings as needed using [single-port](https://gozargah.github.io/marzban/examples/all-on-one-port#یک-پورت-برای-همه), or take action from the second mode.
In this case, you can use all available ports in your environment. Note that in this scenario, all ports used by Xray-Core of the panels will be listened on by the node server. This means that if there is a duplicate port in the Xray core pf the panels, there may be disruptions in node connections or configurations. To avoid this issue, you can configure your settings as needed using [All on one port](https://gozargah.github.io/marzban/en/examples/all-on-one-port) tutorial, or simply follow the second method.

- Use the following example to add two node services to the `docker-compose.yml` file.

Expand All @@ -117,8 +117,7 @@ services:
SERVICE_PORT: 2000
XRAY_API_PORT: 2001
SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert_1.pem"
SSL_CERT_FILE: "/var/lib/marzban-node/ssl_cert.pem"
SSL_KEY_FILE: "/var/lib/marzban-node/ssl_key.pem"
volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
- /var/lib/marzban:/var/lib/marzban
Expand All @@ -141,13 +140,13 @@ services:
```
:::

- Then obtain the required certificate from the panels and place each one in the specified path as indicated in the sample.
- Run Border Node.
- Then get the necessary certificates from the panels and place them in the specified paths.
- Proceed to run Marzban Node
```bash
docker compose up -d
```

- The connection ports of the node to the panels and the usable ports in these enclosures are as follows:
- 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 |
|----------------:|---------:|-------:|
Expand All @@ -157,14 +156,14 @@ docker compose up -d

<br>

### Second Scenario: Using Port Mapping
### Second Method: Using Port Mapping

In this scenario, only specific ports are usable and duplicate ports on the server node will be prevented. Please note that you should specify the ports used in your services in the `docker-compose.yml` file.
In this scenario, only specific ports are accessible and duplicate ports on the server node will be prevented. Please note that you should specify the ports used in your services in the `docker-compose.yml` file.

- Use the example below to add two Node services to the `docker-compose.yml` file.


::: Sample configuration file `docker-compose.yml` details
::: details Sample configuration file `docker-compose.yml`
::: code-group
```yml{7,25} [docker-compose.yml]
services:
Expand Down Expand Up @@ -205,9 +204,9 @@ services:
```
:::

- After receiving the required certificates from the panels and placing them in the specified paths, run the Border Node.
- Once you have received the necessary certificates from the panels and placed them in the specified paths, proceed to run Marzban Node.

- The connection ports of the node to the panels and the usable ports in these bundles will be as follows:
- 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 |
|----------------:|-----------:|---------:|
Expand All @@ -216,19 +215,19 @@ services:
| `Inbound Ports` | 2053 <br> 2054 | 2096 <br> 2097 |


## Updating the marzban node
## Updating Marzban Node

- We enter the Marzban node folder.
- Enter Marzban Node directory.
```bash
cd Marzban-node
```

- We update the node version with the following command.
- Update Marzban Node using the following command.
```bash
docker compose pull
```

- Finally, we restart the marzban node with the following command.
- Finally, restart Marzban Node using the following command.
```bash
docker compose down --remove-orphans; docker compose up -d
```
Expand All @@ -237,29 +236,30 @@ docker compose down --remove-orphans; docker compose up -d
## 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 with different `Tag` and `Port` in the `Core Settings`.
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 2
If you intend to use Warp on the node server and have configured the `docker-compose.yml` file in the second mode, you must enable Warp with the `Xray core`. If using Wireguard core, Warp will not work on the node server.
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 Note 3
If you plan to use TLS-configured settings, you must obtain a certificate for your domain on the node server, then transfer it to the main server and enter the path of certificate files in the inbound. Also, instead of multiple certificates for multiple subdomains, you can get a wildcard certificate for your main domain to be used for all subdomains.
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.
:::


::: tip Note 5
After making changes in the `docker-compose.yml` file, restart Marzban Node with this command:
bash
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
```
:::

::: tip Note 6
Regarding Xray version, if Marzban Node is not on the latest version of Xray and you want to manually upgrade it or downgrade it for any reason through changing Xray-core version according to documentation.
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).
:::

0 comments on commit dfd60ad

Please sign in to comment.