Commit 22bb5110 by arbabnazar

added the nginx redirected logic

parent a6149ea5
...@@ -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";
} }
{{ '{%' }} endif {{ '%}' }}
{{ '{%' }} NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" {{ '%}' }}
# Run our actual redirect... # Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($do_redirect = "true") { 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