Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active February 16, 2018 09:34
Show Gist options
  • Save zulhfreelancer/41f901589e6eb2f40f5eb1f8e90b3fe7 to your computer and use it in GitHub Desktop.
Save zulhfreelancer/41f901589e6eb2f40f5eb1f8e90b3fe7 to your computer and use it in GitHub Desktop.
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