NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.95k stars 2.66k forks source link

Use also as load balancer according to this tutorial - It worked but... #2917

Open hatzisn opened 1 year ago

hatzisn commented 1 year ago

Hello, great work and thanks. Is it possible to use the tutorial as seen in the following video for load balancing?

https://www.youtube.com/watch?v=QE26N9cHE2M

I tried setting the specific .conf file in /data/nginx/proxy_hosts to read/write/execute for everyone and then I "sudo nano" it adding what is mentioned in this video. It worked after restarting NginxProxyManager container but I get redirected to the first only selection. Can you guess on what might have gone wrong and give a piece of advice. A good thing to do is integrate this if you please...

Thanks a lot, again.

silicon2022 commented 1 year ago

Hello hatzisn,

I have created an article about how to load balance your web servers (WordPress) using Nginx Proxy Manager and Cloudflare. You may have a look at it. However, it is just a temporary workaround. Hopefully, the upstream module will be included in the Nginx Proxy Manager UI in v3.

You have to modify your Nginx Proxy Manager built-in configuration files in order to make the upstream module function properly. Moreover, you will need to create some custom configuration files. Try my method on a flash-installed Linux VM/VPS first, as it may mess up your current settings.

I am not familiar with proxy headers. Feel free to correct me if I forget to include some necessary proxy headers.

redtripleAAA commented 1 year ago

@hatzisn I did a loadbalancer setup that works with npm as the follows:

Requirements:

Setup your nginx server (can simply run it as a docker container)

Example:

version: '3.8'
services:
  lb:
    image: nginx:latest
    container_name: web_nginx_bootstrap_loadbalancer-lab-lb
    restart: unless-stopped
    volumes:
    - /volume1/docker/containers/Bootstrap/loadbalancer-lab/lb/config/nginx.conf:/etc/nginx/nginx.conf:ro
    ports:
    - "1010:80"

Make sure to edit your nginx.conf file in the mounted file # nginx.conf

http {

    upstream all {
        server 10.0.12.201:8081;
        server 10.0.12.201:8082;
    }

    server {
         listen 80;
         location / {
              proxy_pass http://all/;
         }
    }

}

events { }

Finally, configure your NPM with a host to point to that LB docker container nginx with the port # 1010 for example.

JS-E commented 1 year ago

Would love this to be a built in feature as i believe it's all just a wrapper over the nginx upstream config anyway. Would be super useful

VijayendraM commented 7 months ago

Would really appreciate to see this feature inbuilt in Nginx Proxy Manager. Load balancing will help achieve high availability of services, in case of hardware failure/security compromised etc (if services are hosted on a single backend host instance.) This feature will make it more attractive to enterprise users.

Grelo4ka commented 5 months ago

Agreed, having some simple load balancing option would be a good to have feature for sure

jader31 commented 2 months ago

I agree: a Load Balance config option (easy like a Apple GUI) would be great. I would be wonderful if it allow not only localaddressess but world wide addresses.

pos-ei-don commented 1 month ago

+1