Skip to content

Instantly share code, notes, and snippets.

@hersonls
Created May 17, 2013 14:28
Show Gist options
  • Save hersonls/5599396 to your computer and use it in GitHub Desktop.
Save hersonls/5599396 to your computer and use it in GitHub Desktop.
Nginx: Nginx, Django and Gunicorn nginx settings
# Gunicorn
#
upstream my_app_name {
server 127.0.0.1:9001;
}
# WWW redirect to non-www
#
server {
server_name www.my-app-name.com.br;
rewrite ^(.*) http://my-app-name.com.br$1 permanent;
}
# Server adjustments
#
server {
listen 80;
server_name my-app-name.com.br;
client_max_body_size 10M;
# Log files
#
access_log /path/to/logs/nginx/access.log;
error_log /path/to/logs/nginx/error.log;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://my_app_name;
break;
}
}
# Cache files
#
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires 30d;
access_log off;
add_header Vary Accept-Encoding;
}
# Static files
#
location /static/ {
autoindex on;
alias /path/to/static/;
}
location /media/ {
autoindex on;
alias /path/to/media/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment