Last active
October 5, 2020 15:53
-
-
Save NickMRamirez/b696134ab567dc1154a1996dcc3663ed to your computer and use it in GitHub Desktop.
Redirect HTTP to HTTPS with HAProxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frontend mywebsite | |
mode http | |
bind :80 | |
bind :443 ssl crt /etc/ssl/certs/ssl.pem | |
default_backend servers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN PRIVATE KEY----- | |
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQC... | |
-----END PRIVATE KEY----- | |
-----BEGIN CERTIFICATE----- | |
MIIFuzCCA6OgAwIBAgIJAIhmZV5h/C6CMA0GCSqGSIb3DQEBCwU... | |
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http-request set-header X-Forwarded-Proto https if { ssl_fc } | |
http-request set-header X-Forwarded-Proto http if !{ ssl_fc } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frontend mywebsite | |
mode http | |
bind :80 | |
bind :443 ssl crt /etc/ssl/certs/ssl.pem | |
http-request redirect scheme https unless { ssl_fc } | |
default_backend servers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http-request redirect scheme https code 301 unless { ssl_fc } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment