HAproxy redirect http to https for selected domain not all domains

frontend http_host
bind    *:80
reqadd X-Forwarded-Proto:\ http
redirect scheme https code 301 if { hdr(host) -i secure.himran.com } !{ ssl_fc }
# Hosts List
acl     host_secure          hdr(host) -i secure.himran.com
acl     host_static             hdr(host) -i static.himran.com
acl     host_patch        hdr(host) -i patch.himran.com
# Use backend for matched host
use_backend http_host_secure if host_secure
use_backend http_host_static if host_static
use_backend http_host_patch if host_patch

# Default for un-match host
default_backend http_host_static

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.