1

I have set up Django's FastCGI + NGINX, but it's only working for root url: any request to http://example.com/anything redirects to http://example.com. Django's internal server working fine, NGINX static file serving and FastCGI processing of the root URL is fine, error log is clear. Here is my config's server section:

server {
        listen       80;
        server_name  example.com;

        location / {
              fastcgi_pass localhost:8000;
              include fastcgi_params;
        }

        location /static/ {
              alias /root/web_development/src/web_development/static/;
        }
}

What am I doing wrong? Thanks in advance.

1
  • What is the content of fastcgi_params? Commented Jan 20, 2010 at 20:40

2 Answers 2

4

Try this configs:

server {
        listen 80;
        server_name example.com;

        location / {
                root /home/example.com/foo;
                fastcgi_pass 127.0.0.1:8000;
                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_pass_header Authorization;
                fastcgi_intercept_errors off;
        }
}

Make sure you've already informed nginx the port which django runs.

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

2 Comments

It's definitely working! Thank you! The problem was in the absence of PATH_INFO parameter in fastcgi_params.
Isn't this setup passing all files through fastcgi? Seems to me that only php files should be matched while other resources should be served directly.
2

You may need to add this line to location /:

fastcgi_split_path_info ^()(.*)$;

from djangoandnginx

Comments

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.