Skip to content

Instantly share code, notes, and snippets.

@dwdraju
Last active November 4, 2018 06:09
Show Gist options
  • Save dwdraju/3a97998ed3bbec22f9626fba0bfaeb89 to your computer and use it in GitHub Desktop.
Save dwdraju/3a97998ed3bbec22f9626fba0bfaeb89 to your computer and use it in GitHub Desktop.
SSL Termination on Load Balancer HTTPS Redirect

Apache

<VirtualHost *:80>
    RequestHeader set X-Forwarded-Proto "http"
    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    ...
</VirtualHost>

Nginx

server {
  if ($http_x_forwarded_proto = "http") {
   return 301 https://$host$request_uri;
  }
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment