Ssl – Prevent HAProxy from redirecting HTTP to HTTPS

apache-2.2haproxyhttphttpsssl

I'm using HAproxy to load balance requests between Apache servers. I'm trying to disable HTTPS for a special use case (serving of kickstart files), and I'm using port 8000 to do this. I have an HAProxy configuration that looks roughly like this (some configuration has been omitted):

frontend provision_frontend_b
        bind 10.1.1.1:8000
        mode http
        default_backend provision_backendb


backend provision_backendb
        mode http
        server server1 127.0.0.1:8000 weight 1
        server server2 10.1.1.2:8000 weight 1

I want HAProxy to redirect requests made to the external IP on port 8000, to the loopback address on port 8000, where I have Apache listening. Apache is configured to serve static files over HTTP.

Strangely, when I hit the server from my browser using the frontend's DNS name: http://myhost.mydomain:8000, I get redirected to HTTPS and an SSL certificate error. When I try with the IP, http://10.1.1.1:8000, it works (and does not redirect to HTTPS).

Is there any reason why HAProxy would do this? It doesn't seem to be Apache, as I've configured HAProxy to redirect to other HTTP-only Apache servers, and still receive this error.

The only thing I see in the HAProxy config is another frontend configured to redirect to SSL:

frontend http_frontend
        bind :80
        mode http
        redirect scheme https if !{ ssl_fc }

However, it is listening on a different port. I attempted to comment the redirect out, and it did not resolve the issue.

Best Answer

No , Its not Haproxy. Haproxy has nothing to do with your https redirection. Looks like the myhost.mydomain was cached in your web browser for an internal 307 redirect. Which will always send your traffic in https mode. Clear out your cache and cookies in the browser, It should work. I am not sure if you could do anything from the server side, I once faced this issue, I tried forcefully redirecting to http scheme but then to many redirects error came up.