Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active February 16, 2018 09:34
HAProxy - redirect http to https

Normal Port: Redirect to HTTPS (80 to 443)

frontend 80
redirect scheme https code 301 if !{ ssl_fc }

Custom Port: Redirect to HTTPS (2052 to 2053)

frontend 2052
http-request replace-value Host (.*):2052 \1:2053
redirect scheme https code 301 if !{ ssl_fc }
@ZsBT
Copy link

ZsBT commented Feb 16, 2018

If there is an old Alfresco or Tomcat behind, they may reply with "Location: http:// ..." redirects that confuse browsers.
I use rspirep ^Location:\ http:(.*) Location:\ https:\1 as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment