1

I have haproxy which listening on ports 80 and 443 and behind Nginx listening locally on ports 8000, 8001, 8002 etc...

By default, all works fine but when an application web made a redirect 301, it redirect with the local port in the response so my firewall drop this when I try to access in the web site.

If I go on the specific URL, the server send me a bad redirection 301 because in the location header, there is the local port.

How say to Haproxy or Nginx do not add local port in location header?

Thanks in advance

PS: My configuration is full https. All websites run on port 443.

4
  • So your application is sending an invalid redirect because it doesn't know the public URL? Sounds to me like you need to change your application. Alternate option may be to try to rewrite the 301 redirect it sends out using Nginx, but not sure if that's possible - better to do it in the application if possible.
    – Tim
    May 22, 2016 at 21:37
  • Also, HAProxy does not add anything to the location header. This sounds like your app. HAProxy could definitely be configured to fix it, by rewriting the header using http-response set-header Location ... or rspirep ^Location: ..., but as @Tim suggests, you'd be better-served by configuring the application itself to return correct redirects. May 23, 2016 at 4:09
  • Phpmyadmin is a good example. When I log in, my browser loop indefinitely because it received the bad url from location header.This is not the only application that causes this problem. I know that haproxy does not change anything in http header. I have set the port_in_redirect to off and I try this proxy_redirect http://example.lan:8000/(.*) https://example.lan/$1; but the header location stay the same. So, the proxy_redirect must be in location /.. or in server block? Because I have other locations block.
    – Body
    May 23, 2016 at 21:35

0

You must log in to answer this question.

Browse other questions tagged .