3

I'm using HAProxy as a load balancer and i'd like to redirect any traffic that comes in on 443 (HTTPS) to 80 (HTTP). My site doesn't support HTTPS at all and i'd rather just redirect users than cause any SSL warnings in browsers.

All I can find is using the redirect location <to> syntax, but as far as I can tell that requires me to hard code the hostname. The load balancer receives connections for various hostnames so would like to keep it relative.

  • 1
    Why would there be any https traffic at all? – Michael Hampton Dec 8 '12 at 22:37
  • If someone hits up the site with https:// I don't want their request to hit a dead end. – tarnfeld Dec 8 '12 at 22:38
  • 1
    They'd still get a certificate warning before the redirect and there is not point serving something that you don't serve ;). Just don't enable https. – Christopher Perrin Dec 8 '12 at 23:04
6

That won't work. If a user enters https://example.com into their browser and it connects to port 443 then it requires SSL to be there. You can't even cause the redirect without having SSL properly set up.

In other words: if a user already connects to 443 then it's too late for you to avoid proper SSL.

Keeping the port closed is probably the "best" thing you can do - apart from getting SSL setup properly.

| improve this answer | |
  • Bah! Of course. Nevermind. – tarnfeld Dec 8 '12 at 23:45
-2

Yes you can, just put the redirect rule in your ssl frontend for the host... something like this

redirect scheme http if { hdr(Host) -i the.host.com } { ssl_fc }
| improve this answer | |
  • Yeah, I know, it's many, many moons later, but did you actually try your suggestion before posting? For you to redirect to https, you'd need to bind to port 443 using a proper SSL certificate - remember that's what the browser expects. The OP said his site did not have SSL configured at all and wasn't planning on setting it up. – AnthonyK Aug 16 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.