How to configure nginx to act as a load balancer for proxies? How to configure nginx to act as a load balancer for proxies? nginx nginx

How to configure nginx to act as a load balancer for proxies?


The nginx docs say upstreams are distributed using a round-robin method.

By default, requests are distributed between the servers using a weighted round-robin balancing method

https://nginx.org/en/docs/http/ngx_http_upstream_module.html


as you can see in your haproxy post haproxy akt as a forward proxy

option http_proxy

What this option mean is described in the manual https://cbonte.github.io/haproxy-dconv/1.6/configuration.html#4-option%20http_proxy

It sometimes happens that people need a pure HTTP proxy which understands basic proxy requests without caching nor any fancy feature. In this case, it may be worth setting up an HAProxy instance with the "option http_proxy" set. In this mode, no server is declared, and the connection is forwarded to the IP address and port found in the URL after the "http://" scheme.

No host address resolution is performed, so this only works when pure IP addresses are passed. Since this option's usage perimeter is rather limited, it will probably be used only by experts who know they need exactly it. This is incompatible with the HTTP tunnel mode.

As far as I know nginx does not have this feature.

A similar question it this.https://superuser.com/questions/604352/nginx-as-forward-proxy-for-https

Why can't you use the haproxy as described in the post of your link?


You would need to configure load balancing rule for proxies either weighted or other

something like max_fails=1 fail_timeout=10s;

        Can you put max_fails =1 and fail_timeout=10s; after the proxies    server localhost:9998 max_fails =1 and fail_timeout=10s;    server localhost:9999 max_fails =1 and fail_timeout=10s;    server localhost:10000 max_fails =1 and fail_timeout=10s;  change location /{        to location @proxy{