Created
June 30, 2014 05:01
-
-
Save gorou-178/694ad9abf7fc01d7bf51 to your computer and use it in GitHub Desktop.
ELB配下のEC2のnginxで、httpをhttpsにリダイレクトする方法。
http://live-cast.asia/blog/2014/06/redirect-https-to-http-in-the-instance-of-the-elb-under-nginx.html
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 / { | |
root /usr/share/nginx/html; | |
index index.html index.htm index.php; | |
set $redirect ""; | |
if ($http_x_forwarded_proto != 'https') { | |
set $redirect "1"; | |
} | |
if ($http_user_agent !~* ELB-HealthChecker) { | |
set $redirect "${redirect}1"; | |
} | |
if ($http_host ~ "www.example.com") { | |
set $redirect "${redirect}1"; | |
} | |
if ($redirect = "111") { | |
rewrite ^ https://$host$request_uri? permanent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment