Skip to content

Instantly share code, notes, and snippets.

@njncalub
Forked from asmallteapot/nginx.conf
Last active August 29, 2015 14:26
Show Gist options
  • Save njncalub/4f9dfb934f2048349653 to your computer and use it in GitHub Desktop.
Save njncalub/4f9dfb934f2048349653 to your computer and use it in GitHub Desktop.
My default Nginx configuration for serving Django projects.
# 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
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