Created
March 14, 2012 19:00
-
-
Save asmallteapot/2038673 to your computer and use it in GitHub Desktop.
My default Nginx configuration for serving Django projects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
In order to match favicon.* (assuming you don't want to match an empty extension), the favicon location regex should be:
^/favicon\.(\w+)$