4

When I query this url

http://mywebsite.com/foos/ 

Django give me :

Page not found (404)
Request Method:     GET
Request URL:    http://mywebsite.com/foos//    
The current URL, , didn't match any of these.

the errors :
- in Request URL it add me '/' at the end,
- in current URL is empty.

my spec :
I run my django website with nginx as reverseproxy to the fast_cgi.

Here my website conf for nginx :

server {
         listen   80;
         server_name  mywebsite.com;


             location / {
                     fastcgi_pass unix:/tmp/_var_wwwdjango_mywebsite.socket;
                     include /etc/nginx/fastcgi_params;
             }
    }

here is my fastcgi_params file :

fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;
fastcgi_param   PATH_INFO               $fastcgi_script_name;
fastcgi_param   SCRIPT_FILENAME         $request_filename;
fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;

fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;

#fastcgi_param  HTTPS                   $server_https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;

remark :

  • if I add url(r'^$', 'myapp.views.index') to my pattern it render me the view for all my requests... so it's clearly a nginx conf or fast_cgi problem.

  • When I execute my website with the django development server my url are ok.

1
  • Please can you update your question to include /etc/nginx/fastcgi_params Commented Feb 15, 2012 at 17:48

1 Answer 1

3

You are missing the PATH_INFO parameter.

fastcgi_param PATH_INFO $fastcgi_script_name;

See the nginx docs: http://wiki.nginx.org/DjangoFastCGI

If you try "nginx PATH_INFO django" in your favourite search engine, it looks like some users had to remove the SCRIPT_NAME parameter as well to get it to work.

Sign up to request clarification or add additional context in comments.

2 Comments

Glad it worked. Did you have to remove SCRIPT_NAME, or was adding PATH_INFO enough?
I don't know the first time I didn't remove it and it wasn't work so I removed and I work ( I don't know because the fist time I forgot to restart nginx )so... If I think I will restest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.