Skip to content

Instantly share code, notes, and snippets.

@kakipo
Last active July 9, 2017 13:46
Show Gist options
  • Save kakipo/057afa060b6e143e8036 to your computer and use it in GitHub Desktop.
Save kakipo/057afa060b6e143e8036 to your computer and use it in GitHub Desktop.
Force Redirect HTTP to HTTPS on nginx behind ELB
# redirect http to https
set $redirect "";
if ($http_x_forwarded_proto != 'https') {
set $redirect "1";
}
if ($http_user_agent !~* ELB-HealthChecker) {
set $redirect "${redirect}1";
}
if ($http_host ~ "your-nifty-domain.com") {
set $redirect "${redirect}1";
}
if ($redirect = "111") {
rewrite ^ https://$host$request_uri? permanent;
}
@kakipo
Copy link
Author

kakipo commented Mar 12, 2015

初めて見たとき感動した設定方法

@lethalbrains
Copy link

👍

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