请原谅我,如果这不是正确的问题。
我有一个由Gunicorn提供的django应用程序,它被NginX逆转,而这个被ISA服务器反转,所以我有以下内容:
ISA --> Nginx --> Gunicorn
ISA将www.mydomain.com/some/path/here
反转为Nginx,这一个将/myapp
反转为Gunicorn(nginx和gunicorn在同一台服务器上)。
问题在于网址,例如访问此应用的基本网址是
www.mydomain.com/some/path/here/myapp/
当django视图中的动作如重定向时,例如:redirect(reverse('start'))
,
网址应该是
www.mydomain.com/some/path/here/myapp/start/
但我得到
www.mydomain.com/some/path/here/some/path/here/myapp/start/
正如您所看到的那样some/path/here/
正在重复,我假设这是由ISA服务器完成的,但我不确定这一点。我在这里做错了什么?
在我的settings.py中,我有:
BASE_PATH = '/some/path/here'
FORCE_SCRIPT_NAME = BASE_PATH + '/myapp'
LOGIN_URL = FORCE_SCRIPT_NAME + '/loginhere/'
urls.py:
...
url(r'^start/', 'testapp.views.start', name='start'),
...
我的nginx.conf:
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
upstream wawared {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/wawared.access.log;
error_log /var/log/nginx/wawared.error.log;
location /static {
root /path/to/static/files;
expires 1d;
gzip on;
}
location /myapp/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8000/;
proxy_redirect off;
}
}
}