Engineer in Tokyo

Django and nginx settings

One problem I keep encountering with setting up fastcgi with Django is that the default nginx fastcgi parameters cause django to load the top url no matter what url you try to go to. This is because the default nginx fastcgi parameters pass the SCRIPT_NAME parameter to the django instance which Django interprets incorrectly. In order to fix this you need to rename the SCRIPT_NAME parameter to PATH_INFO.

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;