Skip to content

Instantly share code, notes, and snippets.

@rafaelks
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelks/833ac71ae97444aaf508 to your computer and use it in GitHub Desktop.
Save rafaelks/833ac71ae97444aaf508 to your computer and use it in GitHub Desktop.
HTTP & HTTPs with Nginx & Gunicorn
upstream my_server {
server unix:/home/user/src/my_project/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
/* ... */
location / {
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://my_server;
}
location ~ ^/(secure-entry|another-secure-entry) {
rewrite ^ https://$host$request_uri? permanent;
}
}
server {
listen 443 ssl spdy;
/* ... */
location ~ ^/(secure-entry|another-secure-entry) {
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://my_server;
}
location / {
rewrite ^ http://$http_host$request_uri? permanent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment