I have java client which talks to 3rd party service through HA Proxy. 3rd party service was recently changed, so now it is returning 302(Moved Temporarily) instead of 200(Ok) which causes failure on my java client cause it expects 200 with actual response. For a number of reasons I want to avoid any code changes to the java client.
So, here is the question: Is there a way to make HA Proxy to follow redirects by itself and only return result(not 3xx http code) to the client?
One more thing to mention: I access HA Proxy via http, HA proxy accesses 3rd party resource via https, and returns 302 with location on https. Location varies, so configure HA Proxy to the new location is not an option.
HA Proxy version: HA-Proxy version 1.7.5 2017/04/03
OS: CentOS Linux release 7.2.1511 (Core)
It seems like you are trying to solve the wrong problem.
It sounds like the site is returning
302
because you are not using HTTPS. So, configure the proxy to use HTTPS.You don't have to access the proxy using HTTPS, but the proxy needs to make the outbound request using HTTPS.
Additionally, HAProxy doesn't do what you are asking about. Responses can be modified as they are being returned, but you cannot force the proxy to follow a redirect.
You can use this
haproxy.conf
handle_redirect.lua
Download
http.lua
from https://github.com/haproxytech/haproxy-lua-http/blob/master/http.lua