我在以下IP上运行本地django服务器,例如2.2.2.2:3000 所以,这就是我的本地django服务器 现在,我带来了一个将(http://www.xyx.com)映射到我的服务器ip的域,即2.2.2.2 现在我的目标是,当我执行http://www.xyx.com/a/b/时,应该将我重定向到我的2.2.2.2:3000/a/b/ 现在唯一起作用的是当我写http://www.xyx.com时,我被重定向到2.2.2.2:3000。多数民众赞成在没有什么像我写的作品 http://www.xyx.com/a/b...I从我带来域名的公司那里得到了这个有趣的页面。我错过了什么?
Here are the config files
# Gunicorn server
upstream django {
server 2.2.2.2:3000;
}
# Redirect all requests on the www subdomain to the root domain
server {
listen 80;
server_name 2.2.2.2;
rewrite ^/(.*) http://2.2.2.2/$1 permanent;
}
# Serve static files and redirect any other request to Gunicorn
server {
listen 80;
server_name 2.2.2.2;
root /var/www/2.2.2.2/;
access_log /var/log/nginx/domain.com.access.log;
error_log /var/log/nginx/domain.com.error.log;
# Check if a file exists at /var/www/domain/ for the incoming request.
# If it doesn't proxy to Gunicorn/Django.
try_files $uri @django;
# Setup named location for Django requests and handle proxy details
location @django {
proxy_pass http://django;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
在我的Django settings.py中 我已将2.2.2.2添加到允许的主机中。