Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In HAProxy, how do I redirect all to HTTPS except for certain domains?

Tags:

https

haproxy

I have HAProxy in front of all my frontend servers working as a load balancer. It redirects all incoming requests to https:

frontend front_http
 mode http
 redirect scheme https if !{ ssl_fc }  
 maxconn 10000
 bind 0.0.0.0:80
 reqadd X-Forwarded-Proto:\ http
 default_backend back_easycreadoc

frontend front_https
 mode http
 maxconn 10000
 bind 0.0.0.0:443 ssl crt /etc/haproxy/ssl.crt
 reqadd X-Forwarded-Proto:\ https
 default_backend back_easycreadoc

We are going to add a few domains for which we do not have a certificate (we do not own those domains, our clients own them). How do I let connections go through on port 80 without redirecting them to https, but only for these domains?

like image 938
jihi Avatar asked Oct 20 '22 11:10

jihi


1 Answers

frontend front_http
 mode http
 acl host_one hdr(host) -i www.one.com
 acl host_two hdr(host) -i www.two.com
 redirect scheme https if !host_one !host_two
 maxconn 10000
 bind 0.0.0.0:80
 reqadd X-Forwarded-Proto:\ http
 default_backend back_easycreadoc

http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#redirect

like image 154
Irvin Choi Avatar answered Dec 20 '22 14:12

Irvin Choi