I recommend to use fastCGI. Last update of wsgi was in 2008 or earlier)
Sample Django.conf for fcgi:
# Django project
server {
listen 80;
server_name www.server.com;
location / {
fastcgi_pass unix:/home/projectname/server.sock;
# fastcgi_pass 127.0.0.1:8000;
include conf/fastcgi.conf;
access_log /logs/nginx_django.log main;
}
location ^~ /admin/ {
fastcgi_pass unix:/home/projectname/server.sock;
include conf/fastcgi.conf;
allow 222.222.0.0/16;
allow 111.111.111.111;
deny all;
access_log off;
auth_basic "Gimme the key!";
auth_basic_user_file /etc/nginx_passwd;
}
location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$ {
root /home/projectname/media;
limit_rate 2000K;
access_log /logs/nginx_django_media.log download;
access_log off;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|bmp|js)$ {
root /home/projectname/static;
access_log off;
expires 30d;
}
}
server {
listen 80;
server_name server.com;
rewrite ^(.*)$ http://www.server.com$1;
access_log /logs/nginx_django.log main;
}
Fastcgi.conf
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_SOFTWARE "nginx";
fastcgi_param GATEWAY_INTERFACE "CGI/1.1";
fastcgi_param UID_SET $uid_set;
fastcgi_param UID_GOT $uid_got;
# fastcgi_param SCRIPT_NAME $fastcgi_script_name;
At last:
su www -c "./manage.py runfcgi method={threaded | prefork} {socket=/home/projectname/server.sock | host=127.0.0.1 port=8000} pidfile=/home/projectname/server.pid"
Good luck!