Created
February 24, 2013 18:35
-
-
Save jasonamyers/5024959 to your computer and use it in GitHub Desktop.
nginx to gunicorn proxy.
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 appname { | |
#server unix:/tmp/gunicorn.sock fail_timeout=0; | |
# For a TCP configuration: | |
server 127.0.0.1:5000 fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name www.appname.com; | |
rewrite ^ https://$server_name$request_uri? permanent; | |
} | |
server { | |
listen 443 ssl; | |
client_max_body_size 4G; | |
server_name www.appname.com; | |
keepalive_timeout 300; | |
ssl_certificate /opt/appname/appname.com.chained.crt; | |
ssl_certificate_key /opt/appname/appname.com.key; | |
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; | |
ssl_ciphers HIGH:!aNULL:!MD5; | |
# path for static files | |
root /opt/appname/nginx-static; | |
location / { | |
# checks for static file, if not found proxy to app | |
try_files $uri @proxy_to_app; | |
} | |
location @proxy_to_app { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://appname; | |
} | |
error_page 500 502 503 504 /500.html; | |
location = /500.html { | |
root /opt/appname/nginx-static; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment