Skip to content

Instantly share code, notes, and snippets.

@kevana
Created November 30, 2015 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevana/cda1908b3abd446392e3 to your computer and use it in GitHub Desktop.
Save kevana/cda1908b3abd446392e3 to your computer and use it in GitHub Desktop.
Poor man's HTTPS redirect.
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