Пример для Gunicorn - предпологается, что он установлен и работает:
..nginx.conf
# Django running with Gunicorn
upstream hello_django_project {
server unix:/home/natsume/myproject/hello_django/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.django-nginx.com;
client_max_body_size 4G;
access_log /home/natsume/myproject/logs/nginx-access.log;
error_log /home/natsume/myproject/logs/nginx-error.log;
location /static/ {
alias /home/natsume/myproject/hello_django/static/;
}
location /media/ {
alias /home/natsume/myproject/hello_django/media/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
# Try to serve static files from nginx, no point in making an
# *application* server like Unicorn/Rainbows! serve static files.
if (!-f $request_filename) {
proxy_pass
http://hello_django_project;
break;
}
# Error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/natsume/myproject/hello_django/static/;
}
}
}