2

To see an example: load up a example.com, click on a link that's linking to /test and instead of going to http:// example.com/test/ it goes to http:// www.example.net//test/

Or if you login, the login form for the auto-generated django admin section posts to //admin instead of admin.

Seems like this is a django issue, but the only thing I changed was nginx.

Couple of additional notes (added Oct 31):

Here is the nginx fastcgi_conf:

#fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_FILENAME    $fastcgi_script_name;
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  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  PATH_INFO          $fastcgi_script_name;

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

Django project config

server {
        listen  80;
        server_name www.site.net;

        location / {
            fastcgi_pass unix:/path/to/site/server.sock;
            include     fastcgi.conf;
            access_log  /var/log/nginx_django.log  main;
        }

        location ^~ /admin/$ {
            fastcgi_pass unix:/path/to/site/server.sock;
            include  fastcgi.conf;
            access_log  /var/log/nginx_django.log  main;
        }

        location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg))
$ {
            root   /path/to/site/media;
            limit_rate 2000K;
            access_log  /var/log/nginx_django_media.log  download;
            access_log   off;
        }

        location ^~ /static/ {
            root   /path/to/site;
            access_log   /var/log/nginx_django_static.log download;
            expires      30d;
        }

        location /403.html {
            root   /opt/nginx;
            access_log   off;
        }

        location /401.html {
            root   /opt/nginx;
            access_log   off;
        }

        location /404.html {
            root   /opt/nginx;
            access_log   off;
        }

        location = /_.gif {
            empty_gif;
            access_log   off;
        }

}
2
  • Um.. it would help seeing the nginx config. Commented Oct 30, 2010 at 2:20
  • My current hypothesis is that Nginx is not respecting the FORCE_SCRIPT_NAME config option in settings.py, while Apache does. This issue was replicated with Apache when I switched back, but went away when I uncommented the FORCE_SCRIPT_NAME parameter. Also, you can set it to garbage and NGINX will ignore it. Commented Nov 1, 2010 at 13:39

1 Answer 1

3
fastcgi_param  SCRIPT_NAME        '';

This solve the // problem for me.

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

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.