I've setup nginx, fastcgi and django. The run my django project through fastcgi using:
python26 manage.py runfcgi host=127.0.0.1 port=8080 --settings=settings
When I visit http://127.0.0.1 I can see the normal django 404 since I haven't setup everything on my django project aside from the admin. So I tried visinting http://127.0.0.1/admin and it returns a 502 bad gateway error.
I checked the logs and here's what I've found. Anybody who knows what's causing this error?
2010/10/15 23:09:34 [error] 4796#0: *1 FastCGI sent in stderr: "" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /admin/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:8080", host: "localhost"
2010/10/15 23:09:34 [error] 4796#0: *1 FastCGI sent in stderr: "Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/flup/server/fcgi_base.py", line 574, in run
protocolStatus, appStatus = self.server.handler(self)
File "/usr/lib/python2.6/site-packages/flup/server/fcgi_base.py", line 1159, in handler
result = self.application(environ, start_response)
File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 245, in __call__
response = middleware_method(request, response)
File "/usr/lib/python2.6/site-packages/django/contrib/sessions/middleware.py", line 36, in process_response
request.session.save()
File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/db.py", line 56, in save
session_key = self.session_key,
File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/base.py", line 152, in _get_session_key
self._session_key = self._get_new_session_key()
File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/base.py", line 144, in _get_new_session_key
if not self.exists(session_key):
File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/db.py", line 29, in exists
Session.objects.get(session_key=session_key)
File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 336, in get
num = len(clone)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 81, in __len__
self._result_cache = list(self.iterator())
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 269, in iterator
for row in compiler.results_iter():
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 672, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 726, in execute_sql
cursor =
BTW I'm running nginx07 and django1.2.
UPDATE:
Here's my nginx configs:
user apache apache;
worker_processes 4;
error_log /var/log/nginx/error_log info;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75 20;
ignore_invalid_headers on;
index index.html;
server {
listen 80;
server_name localhost;
location /site_media {
root /media/; # Notice this is the /media folder that we create above
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov) {
access_log off;
expires 30d;
}
location / {
# host and port to fastcgi server
fastcgi_pass 127.0.0.1:8080;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log;
}
}