I am using NGINX as a load balancer to route all traffic on example.com to one of the two servers. It works fine if there is no path added to the URL https://example.com but if there is a path https://example.com/legal then I get an error:
could not resolve host servers:8080
It seems like the path that is added to the URL makes nginx "forget" about the servers variable and it treats it like a real domain, which is obviously not working.
My NGINX config:
upstream servers {
server 192.0.0.1:8080;
server 192.0.0.2:8080;
}
server {
listen 80;
server_name example.com;
return 302 https://example.com$uri$is_args$args;
}
server {
listen 443;
server_name example.com;
// ssl config and certs
location / {
proxy_pass http://servers;
}
}
What setting am I missing here?