看一个例子:加载一个example.com,点击一个链接到/ test的链接,而不是去http:// example.com/test/去http:// www.example.net //testing/
或者,如果您login,自动生成的djangopipe理部分的login表单发布到// admin而不是admin。
似乎这是一个Django的问题,但我改变的唯一的事情是nginx。
#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;
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; } }
fastcgi_param SCRIPT_NAME '';
这为我解决了问题。