I am using HAProxy to redirect traffic to different web servers in local network.
Without SSL enabled, I can route based on hostname like this (in frontend section):
acl is_local hdr_end(host) -i mirror.skbx.co
acl is_kiev hdr_end(host) -i kiev.skbx.co
use_backend kiev if is_kiev
default_backend wwwlocalbackend
As soon as I enable SSL, everything works in TCP mode via Pass through SSL mode.
But I also need to make sure HTTP is redirected to HTTPS. When I use:
redirect scheme https if !{ ssl_fc }
in my HTTP frontend section of HAProxy config, I get all requests redireted to default backend, so the above-mentioned acl rules are ignored if the request is redirected from redirect scheme
.
This question has an answer on how to get it working via SSL Termination, where SSL is stripped down at HAProxy level.
My question is - is HTTP to HTTPS redirect possible while retaining pass-through (mode tcp)?
Full config of frontend and backend sections I have is in this gist.