Website auto redirecting when hosted on HAProxy

We are in the process of migrating from Apache reverse proxy to
HAProxy. We are facing issues with some of the web sites. Any
recommendation will be greatly appreciated.

We have hosted all application on HAProxy with the needed SSL
Certificates. All our sites are SSL, there is no non ssl site in our

e.g. https :// is on HAProxy

Env Configuration:
https :// should forward the request to http :// on the backend. The backend i.e. is not HTTPS it is only http site. So we are proxying HTTPS site to a backend http site.

Expected behaviour (Which is not working):
When we access the site https :// it should auto forward to login page i.e. https :// – (this autoforward is the application behavior )


When we access as https :// the URL in the browser gets changed automatically to http: //

Since HAProxy is not listening on port 8080 the site gives error “Page cannot be displayed”

When the login page is accessed with full url i.e. https :// it loads fine, but on entering the domain only i.e. https :// it ends up in “page cannot be displayed” error
This configuration is working smoothly with apache as reverse proxy, the configuration of apache is also provided below.

The HA Proxy configuration is as below

frontend http-in
bind *:443 ssl crt /etc/pki/tls/certs/mysite/ crt /etc/pki/tls/certs/mysite1/
mode http
acl req.hdr(Host)
acl path_mirror_app1 path -m beg /app1
use_backend mysite.com_redirect if path_mirror_app1

backend mysite.com_redirect
http-request set-header Host
server check
mode http

Apache Configuration

The apache configuration for the same site which is working fine is as below

<VirtualHost *:443>
ProxyPass /
ProxyPassReverse /

SSLEngine On
SSLProxyEngine On
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite HIGH:!aNULL:!eNULL:!RC4
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLCertificateFile /etc/pki/tls/certs/mysite/
SSLCertificateKeyFile /etc/pki/tls/certs/mysite/


You are configuring haproxy to only foward this to the backend when the URI begins with /app1, this is not the case when you are only pointing your browser to, which of course does not work as expected then.

Whatever your default_backend is pointing to, it will hit that instead of your “mysite.com_redirect” backend.

I tried configuring “acl path_mirror_app1 path -m beg /” but the same redirection issue still persists. When i try to access the site with the domain name, the URL in browser gets autochanged to http.

I assume your backend has some problem with the host header not showing 8080.

Try modifying the Host header:
http-request set-header Host