我有两个域名www.blog.com
和www.project.com
目前,www.blog.com/project
指向我的项目页面。我已经将nginx配置为将任何请求重定向到我的Django项目{/ 1}}。
我刚刚购买了/project
,我希望它显示与www.project.com
相同的内容,而不会在浏览器中更改网址。我不确定是否有办法通过DNS执行此操作(重定向无法保留网址),或确定请求是来自www.blog.com/project
还是{{1}的方法在服务器级别。
简而言之:
www.blog.com
一直指向root www.project.com
需要继续转发给Django blog.com
现在需要显示在浏览器栏中并执行类似2. 答案 0 :(得分:0)
理查德史密斯钉了它。创建一个新的服务器块是要走的路。我已经包含.conf文件的相关部分,以防任何人遇到此问题。
server {
listen 80;
server_name .project.com;
# set max upload size
client_max_body_size 2G;
fastcgi_buffers 64 4K;
access_log /var/log/nginx/wordpress_http_access.log combined;
#There were some shortsighted design decisions that meant it had to be
# served from /project/ to avoid breaking a bunch of relative links.
location = / {
return 301 http://www.project.com/project/;
}
location /project/ {
uwsgi_pass django;
include /home/project/uwsgi_params;
}
# Django media
location ^~ /project/media/ {
alias /home/project/media/;
autoindex off;
}
location /project/static/ {
alias /home/project/static/;
}
}