Last active
August 29, 2015 14:13
-
-
Save rafaelks/833ac71ae97444aaf508 to your computer and use it in GitHub Desktop.
HTTP & HTTPs with Nginx & Gunicorn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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