Created
November 30, 2015 18:57
-
-
Save kevana/cda1908b3abd446392e3 to your computer and use it in GitHub Desktop.
Poor man's HTTPS redirect.
This file contains hidden or 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
location /statement { | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Server $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_http_version 1.1; | |
proxy_set_header Connection ""; | |
# Redirect to https if the protocol is http and the cookie is set | |
set $send_to_https 1; | |
if ($cookie_bcp_active__my_account != "Y") { | |
set $send_to_https 0; | |
} | |
if ($scheme = "https") { | |
set $send_to_https 0; | |
} | |
if ($send_to_https) { | |
rewrite ^ https://$http_host$request_uri? redirect; | |
} | |
proxy_pass http://$upstream_live_bcp_active__my_account; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment