Commit c26d5597 by Arbab Nazar

Merge pull request #2686 from edx/arbab/mod-cookie-cutter

added the nginx redirected logic
parents 9ef69789 be111597
...@@ -58,13 +58,29 @@ server { ...@@ -58,13 +58,29 @@ server {
proxy_pass http://{{ role_name }}_app_server; proxy_pass http://{{ role_name }}_app_server;
} }
# Forward to HTTPS if we're an HTTP request... # Nginx does not support nested condition or or conditions so
if ($http_x_forwarded_proto = "http") { # there is an unfortunate mix of conditonals here.
set $do_redirect "true"; {{ '{%' }} if NGINX_REDIRECT_TO_HTTPS {{ '%}' }}
{{ '{%' }} if NGINX_HTTPS_REDIRECT_STRATEGY == "scheme" {{ '%}' }}
# Redirect http to https over single instance
if ($scheme != "https")
{
set $do_redirect_to_https "true";
} }
# Run our actual redirect... {{ '{%' }} elif NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" {{ '%}' }}
if ($do_redirect = "true") {
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($http_x_forwarded_proto = "http")
{
set $do_redirect_to_https "true";
}
{{ '{%' }} endif {{ '%}' }}
# Execute the actual redirect
if ($do_redirect_to_https = "true")
{
rewrite ^ https://$host$request_uri? permanent; rewrite ^ https://$host$request_uri? permanent;
} }
{{ '{%' }} endif {{ '%}' }}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment