# Step-by-Step Guide to Load Balancing with Nginx Proxy Manager

Link: [https://blog.devomkar.com/load-balancer-nginx-proxy-manager/](https://blog.devomkar.com/load-balancer-nginx-proxy-manager/)

<div class="single-meta" id="bkmrk-jan-10%2C-2024%C2%A0%C2%A02-min-" style="text-align: justify;"><span class="single-meta-item single-meta-date"><time datetime="2024-01-10">JAN 10, 2024 </time></span><span class="single-meta-item single-meta-length"> 2 MIN READ </span><span class="single-meta-item single-meta-tag"> [DOCKER](https://blog.devomkar.com/tag/docker/)</span></div><div class="single-meta" id="bkmrk-" style="text-align: justify;"></div>Load balancing is a crucial aspect of managing web traffic efficiently, ensuring high availability, and optimizing resource utilization. Nginx Proxy Manager is a powerful tool that simplifies the process of setting up and managing reverse proxies with load balancing capabilities. In this step-by-step guide, we'll walk through the process of configuring load balancing using Nginx Proxy Manager.

### Prerequisites:

<div class="single-meta" id="bkmrk-nginx-proxy-manager-" style="text-align: justify;">1. Nginx Proxy Manager installed and running.
2. Access to the Nginx Proxy Manager web interface.
3. Knowledge of the IP addresses and ports of your backend servers.

</div>### Step 1: Access Nginx Proxy Manager Web Interface

Open your web browser and navigate to the Nginx Proxy Manager web interface. Typically, it's accessible at `http://your-server-ip:81`. Log in using your credentials.

### Step 2: Create Custom Configuration Snippet

<div class="single-meta" id="bkmrk-connect-to-your-serv" style="text-align: justify;">- Connect to your server where Nginx Proxy Manager is installed.
- Navigate to the location where you have mounted the Nginx configuration files. In this case, it's /data/nginx/custom/.

<div class="code-toolbar"></div></div>```console
cd /data/nginx/custom
```

<div class="single-meta" id="bkmrk-copy-create-a-new-fi" style="text-align: justify;"><div class="code-toolbar"><div class="toolbar"><div class="toolbar-item"><button class="copy-to-clipboard-button" data-copy-state="copy" type="button">Copy</button></div></div></div>- Create a new file named http\_top.conf:

<div class="code-toolbar"></div></div>```console
touch http_top.conf
```

<div class="single-meta" id="bkmrk-copy-edit-the-file-u" style="text-align: justify;"><div class="code-toolbar"><div class="toolbar"><div class="toolbar-item"><button class="copy-to-clipboard-button" data-copy-state="copy" type="button">Copy</button></div></div></div>- Edit the file using a text editor (e.g., nano or vim):

<div class="code-toolbar"></div></div>```console
nano http_top.conf
```

<div class="single-meta" id="bkmrk-copy-add-the-followi" style="text-align: justify;"><div class="code-toolbar"><div class="toolbar"><div class="toolbar-item"><button class="copy-to-clipboard-button" data-copy-state="copy" type="button">Copy</button></div></div></div>- Add the following upstream block to the file, specifying the IP addresses and ports of your backend servers:

<div class="code-toolbar"></div></div>```console
upstream backend {
    server 192.168.0.69:8080;
    server 192.168.0.100:8090 backup;
}
```

<div class="single-meta" id="bkmrk-copy" style="text-align: justify;"><div class="code-toolbar"><div class="toolbar"><div class="toolbar-item"><button class="copy-to-clipboard-button" data-copy-state="copy" type="button">Copy</button></div></div></div></div>Save the changes and exit the text editor.

### Step 3: Add Custom Configuration in Nginx Proxy Manager

<div class="single-meta" id="bkmrk-in-the-nginx-proxy-m" style="text-align: justify;">- In the Nginx Proxy Manager dashboard, click on the "Proxy Hosts" tab in the left sidebar.
- Click the "Add Proxy Host" button to create a new reverse proxy configuration.
- Fill in the necessary details in the basic configuration (Domain Names, Forward Hostname/IP, Forward Port, etc.).
- Navigate to the "Advanced" tab.
- In the "Custom Nginx Configuration" section, add the following

<div class="code-toolbar"></div></div>```console
location / {
    proxy_pass http://backend;
}
```

<div class="single-meta" id="bkmrk-copy-save-the-proxy-" style="text-align: justify;"><div class="code-toolbar"><div class="toolbar"><div class="toolbar-item"><button class="copy-to-clipboard-button" data-copy-state="copy" type="button">Copy</button></div></div></div>- Save the proxy host configuration.

</div>### Step 4: Test and Verify

<div class="single-meta" id="bkmrk-after-saving-the-con" style="text-align: justify;">1. After saving the configuration, test the load balancing setup by accessing your domain or subdomain in a web browser.
2. Monitor the Nginx Proxy Manager dashboard and the access logs to ensure that requests are being distributed among the backend servers.

</div>For more information on HTTP Load Balancing in NGINX click [here](https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/?ref=blog.devomkar.com).

Congratulations! You have successfully set up load balancing using custom Nginx configuration snippets in Nginx Proxy Manager. Adjust the configuration as needed and scale your infrastructure to handle increased traffic efficiently.