help: local server ports show up in the URL served to users #1465
-
I have NGINX Proxy Manager running in Ubuntu 20. I recently noticed that the local port number is being inserted into the URL served to users: I don't think this is expected behavior of reverse proxy, correct? The NGINX GUI created a config file for each of the proxy hosts. excerpt from proxy host config file:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Are you sure that it's not the app running behind the proxy which inserts the port number? Because as you said, nginx itself should not insert the proxied IP into the served url. |
Beta Was this translation helpful? Give feedback.
-
After looking at this closer, I'm sure there's a problem, but I'm not sure where the problem is occurring! The app behind the NGINX proxy manager is an NGINX web server, running in a Raspberry Pi in my local network. When I go through the NGINX Proxy manager using the http://xyz.duckdns.org URL, I am succesfully taken to the Raspberry Pi's NGINX web server. It's looking like only the main web page loads reliably through the NGINX Proxy Manager, and the sub-pages barely work. Something is clearly broken, but I'm not sure where to focus the diagnostics. |
Beta Was this translation helpful? Give feedback.
-
I think I mischaracterized what was going on. On the NGINX proxy manager side: |
Beta Was this translation helpful? Give feedback.
-
It did turn out that the nginx web server needed a configuration tweak. I discovered that if I added a trailing slash to the links in my pages, they worked! I found that adding "absolute_redirect off;" or "port_in_redirect off;" or both to the server section of the /etc/nginx/sites-available/default file fixes the problem, and :8080 does not get inluded in URLs served to the users.
After restarting the xginx web server with "sudo systemctl reload nginx", then all the links to the sub-pages worked properly, and had trailing slashes at the ends of their URLs. |
Beta Was this translation helpful? Give feedback.
It did turn out that the nginx web server needed a configuration tweak.
I discovered that if I added a trailing slash to the links in my pages, they worked!
It turns out that NGINX web server redirects to port 8080 when the link URL doesn't have a trailing slash.
This is explained here: https://serverfault.com/questions/227742/prevent-port-change-on-redirect-in-nginx
I found that adding "absolute_redirect off;" or "port_in_redirect off;" or both to the server section of the /etc/nginx/sites-available/default file fixes the problem, and :8080 does not get inluded in URLs served to the users.