Nginx forwarding to a different port

nginxPROXY

Alright so I'm using nginx to forward communication to and from my server and clients. My server receives the communication via port 6543, and nginx forwards it to that port on that server (from port 80 on the nginx proxy server)

It works fine if I enter http://mydomain.com/directory/ <- note the trailing slash

but if i enter http://mydomain.com/directory <- no trailing slash

it becomes http://mydomain.com:6543/directory/ which of course doesn't work, because the nginx server isn't expecting anything on that port.

I can't figure out how to fix this. Help?

Best Answer

You need to set port_in_redirect to off on the back-end server use proxy_redirect on the front-end server.