0
votes

I'm using HAProxy for load balancing and only want my site to support https. Thus, I'd like to redirect all requests on port 80 to port 443.

How would I do this?

Edit: We'd like to redirect to the same url on https, preserving query params. Thus, http://foo.com/bar would redirect to https://foo.com/bar

 frontend httpfront
    mode http
    bind *:80
    redirect scheme https code 301 if !{ ssl_fc }
1

1 Answers

3
votes

You need configure frontend for 443 port.

frontend (port 80) -> frontend (port 443) -> backend

Check my example:

frontend httpfront
    mode http
    bind *:80
    redirect scheme https code 301 if !{ ssl_fc }

frontend httpsfront
    mode tcp
    bind *:443
    default_backend app

backend app
    mode tcp
    balance roundrobin
    server server01 10.10.10.11:443 check
    server server02 10.10.10.12:443 check