Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
nginx to gunicorn proxy.
upstream appname {
#server unix:/tmp/gunicorn.sock fail_timeout=0;
# For a TCP configuration:
server fail_timeout=0;
server {
listen 80;
rewrite ^ https://$server_name$request_uri? permanent;
server {
listen 443 ssl;
client_max_body_size 4G;
keepalive_timeout 300;
ssl_certificate /opt/appname/;
ssl_certificate_key /opt/appname/;
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
You can’t perform that action at this time.