Skip to content

Instantly share code, notes, and snippets.

@pyzen
Forked from asmallteapot/nginx.conf
Last active August 29, 2015 14:01
Show Gist options
  • Save pyzen/3460ed0cc5dbd6f271e4 to your computer and use it in GitHub Desktop.
Save pyzen/3460ed0cc5dbd6f271e4 to your computer and use it in GitHub Desktop.
# file: /etc/nginx/sites-available/example.com
# nginx configuration for example.com
server {
listen 80;
server_name example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
# pass root to django
location / {
include uwsgi_params;
uwsgi_pass unix://tmp/example.sock;
# disallow .py, .wsgi, and .conf
}
# serve django static files
location /static {
root /srv/www/example.com/site;
}
# alias robots.txt to static
#need to append '$' or else nginx appending '/' and giving directory listing error
location /robots.txt$ {
alias /srv/www/example.com/site/static/robots.txt;
}
# alias favicon.* to static
location ~ ^/favicon.(\w*)$ {
alias /srv/www/example.com/site/static/favicon.$1;
}
# alias stylesheets to static
location ~ ^/([^/]*\.css)$ {
alias /srv/www/example.com/site/static/css/$1;
}
# serve django uploaded media
location /media {
root /srv/www/example.com/site;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment