[Django]-What does the proxy_pass option in the NGINX config do?

10đź‘Ť

Take a look at nginx’s HttpProxyModule, which is where proxy_pass comes from. The proxy_pass docs say:

This directive sets the address of the proxied server and the URI to
which location will be mapped.

So when you tell Nginx to proxy_pass, you’re saying “Pass this request on to this proxy URL”.

There’s also documentation on upstream available:

This directive describes a set of servers, which can be used in
directives proxy_pass and fastcgi_pass as a single entity.

So the reason that you use upstream for proxy_pass is because proxy_pass is expecting one URL, but you want to pass it more than one (so you use an upstream).

If your load balancer is in front of your nginx, your load balancer URL won’t be in this config.

👤girasquid

0đź‘Ť

It should be:
proxy_pass http://my-upstream;

nginx will load-balance all requests over your 4 djano+gunicorn instances (your my-upstream). The load-balancers will point to the nginx servers.

👤Lars Hansson

Leave a comment