1. Vladimir Mihailenco
  2. django-fab-deploy

Source

django-fab-deploy / fab_deploy / config_templates / nginx.config

server {
    listen 80;
    server_name {{ SERVER_NAME }} www.{{ SERVER_NAME }};
    access_log /var/log/nginx/{{ INSTANCE_NAME }}.access.log;
    charset utf-8;
    client_max_body_size 8m;

    gzip_types text/plain text/xml text/css application/javascript application/x-javascript application/json;

    location / {
        proxy_pass http://localhost:{{ APACHE_PORT }};
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    # change /static to your static folder name
    location /static {
        root {{ PROJECT_DIR }};
        autoindex off;
        expires 1M;
    }

    # admin media serving
    # (this location is available if django is installed from svn)
    location /media {
        root {{ ENV_DIR }}/src/django/django/contrib/admin;
        expires 10m;
        autoindex off;
    }

    # alternative django admin media path
#    location /static/admin {
#        root {{ PROJECT_DIR }};
#        autoindex off;
#        expires 10m;
#    }

    #error_page  404  /404.html;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/nginx-default;
    }
}