[SOLVED] Haproxy caching redirect location?

Hello everyone :slight_smile:

I need sone help to understand http-request redirect location.
I’m using HA-Proxy version 2.2.9-2+deb11u3 2022/03/10

I want a basic redirection like:

acl redirect_test1 -i hdr_beg(Host) -i test1.
http-request redirect location https://test2.server.com code 301 if redirect_test1

It works, but I initially made a typo error (teste2 instead test2) on the redirect location URL.
So now everything is redirected to my url with the typo error.

I tried to change my redirect URL, but URL is still redirecting to my old url :frowning:
I guess there is a cache inside haproxy ? (I tried to change my browser and clear the cache in case cache is also on this side, but no chance)

FYI, when I curl my url:

< HTTP/1.1 301 Moved Permanently
< location: https://teste2.server.com

How can I fix this ?

Thank you very much !

It’s not cached by haproxy but in the browser. Delete the browser cache and restart the browser completely.

Haproxy by default uses 302 Moved temporarily, which is not cached by browser.

Also see the docs:

http://docs.haproxy.org/2.6/configuration.html#4.2-redirect%20location

      The code is optional. It indicates which type of HTTP redirection
      is desired. Only codes 301, 302, 303, 307 and 308 are supported,
      with 302 used by default if no code is specified. 301 means
      "Moved permanently", and a browser may cache the Location. 302
      means "Moved temporarily" and means that the browser should not
      cache the redirection.
1 Like

Thank you Lukastribus,

Unfortunately, like I said, I already tried to clear the cache, changing browser, etc…
Always the same.

I changed the configuration, right now I use a 302.
But no chance :frowning:

Haproxy was restarted.

edit: hum, i tried something with curl and it’s working…

curl -H 'Cache-Control: no-cache' http://www.example.com
< HTTP/1.1 302 Found
< location: https://test2.server.com
< cache-control: no-cache

Really strange as a brand new browser without cache still redirecting me to the wrong URI…

edit:
something is really weird

First try => curl -v https://test1.server.com

< HTTP/1.1 302 Found
< content-length: 0
< location: https://test2.server.com
< cache-control: no-cache

Second try one second later after the first try: curl -v https://test1.server.com

< HTTP/1.1 301 Moved Permanently
< content-length: 0
< location: https://teste2.server.com

I changed my haproxy conf by a 302 now

:thinking: :thinking:

In this case it’s likely that the haproxy instance running the old configuration is still running and accepting requests, because in this case the kernel load balances between the old and new process, so that is why the result is inconsistent.

Stop haproxy completely, and then check if there are still haproxy processes running. Kill them all and start haproxy again.

1 Like

Thank you, that’s was the issue !

1 Like