When the load balancer gets a redirect (as some of the pages on the site will do), it includes port 8001 in the redirect, e.g. http://app.example.com:8001/some/url instead of http://app.example.com/some/url.

How can I fix this? I've tried setting proxy_redirect to off, but it has no effect.

This sounds like your application is causing the problem.
–
Michael Hampton♦Jan 31 '14 at 17:43

@MichaelHampton Can you be more specific? Is there some header that the application should be sending? From a web search, this seems like a common problem with nginx, but none of the suggested solutions appear to work.
–
RobJan 31 '14 at 17:51

@MichaelHampton The application is redirecting as if the user agent is connected directly to it, which is what the application should be doing. nginx is rewriting the Location headers in redirects, but it is not changing the port. So it seems that the problem is nginx or how it is configured.
–
RobFeb 3 '14 at 8:55