1
我是nginx的新手,我试图让我的second.domain.com显示first.domain.com/dir的内容,(在端口3000上运行)我的本地主机)网上通缉后,似乎这才是解决nginx不会将根目录更改为子目录
# this one works fine
server {
listen 80;
server_name first.domain.com;
location/{
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
# this one doesn't work as expected
server {
listen 80;
server_name second.domain.com;
location/{
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
root /dir;
index index.html;
}
}
,但是当我访问second.domain.com我得到相同的根first.domain.com而非first.domain.com/dir ...任何人都可以看到我做错了什么?
您的位置设置自/至/博客,并在其中添加重写规则一样'改写/blog/(.*)/ $ 1 break;' –
如何在同一服务器conf中使用它们,如果它们具有不同的server_name? – Nick
对不起老兄,我半睡半醒。删除该部分。 :) –