HTTP redirect backend error

Hi Dudes!

I´m starting with the HAProxy and I found my first problem. I have a site wich in a direct access everything goes well, but when I try to access through HAProxy, some images isn´t showed.

The site use HTTP redirects,as we can see in logs with the 302 HTTPS response code. Is this the reason?

Sep 10 10:59:10 localhost haproxy[641]: xxx.xxx.xxx.xxx:6999 [10/Sep/2018:10:59:10.000] https-in~ sisjur_servers/sisjur01 0/0/3/15/18 302 510 - - ---- 2/2/1/1/0 0/0 “GET /SISDPVATJUR/App_Themes/img/Msg_erro.jpg HTTP/1.1”
Sep 10 10:59:10 localhost haproxy[641]: xxx.xxx.xxx.xxx:7000 [10/Sep/2018:10:59:10.017] https-in~ sisjur_servers/sisjur01 0/0/2/13/15 302 510 - - ---- 2/2/0/0/0 0/0 “GET /SISDPVATJUR/App_Themes/img/pbar-ani.gif HTTP/1.1”

What can I do to solve this problem?

Thanks in advance!
Renato Souza

Understand where that request is pointing to, and check why that destination fails. Also consider that your backend server may redirect forever if it doesn’t like something about the request from haproxy (for example: it may try to redirect to https, while haproxy only talks to the backend server on port 80).

Understand why and where to your application redirects is crucial to solving this problem, as it is not really a haproxy problem.

Sadly the application has many redirect and developers can’t track everything now. I’ll try another solution.

Thanks for your help!

They may have many redirects and can’t disable them, but when you understand why the redirect happens, you may be able to do something about it with haproxy.

For example, when the redirect is to SSL because the application doesn’t understand that it may already be on SSL, setting the X-Forwarded-Proto can help your application.

Or when the application expects a different host header in the requests, you can rewrite it so that the application is happy.

Understanding why the redirect happens is necessary to evaluate the solutions, it doesn’t mean your application has to change.

Make sense, I´ll try! :slight_smile:

Thanks again!