Skip to content

Instantly share code, notes, and snippets.

@ProfFan
Created July 31, 2014 15:40
Show Gist options
  • Save ProfFan/3765b1795cf74bf31c04 to your computer and use it in GitHub Desktop.
Save ProfFan/3765b1795cf74bf31c04 to your computer and use it in GitHub Desktop.
Force Full Site SSL with non-SSL redirecting
server {
listen your-ip:80 default_server;
server_name ex1.ex.net;
server_name ex2.ex.net;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
ssl on;
ssl_certificate /certs/ssl.crt;
ssl_certificate_key /certs/ssl.key;
root /wwwroot;
server_name ex1.ex.net;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host; # !IMPORTANT: Hard to debug
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:1234/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment