如何使用 nginx 在子域上禁用域代理重定向?
How to disable domain proxy redirect on a subdomain with nginx?
我的 nginx 上有三个文件 conf.d -
example.com
www.example.com
other.example.com
example.com 是我的首选域,是传递 nodejs 应用程序的代理。
example.com 具有以下配置
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:8081;
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;
}
}
www.example.com 具有以下配置:
server{
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
在其他example.com我有以下配置
server {
listen 80;
server_name other.example.com;
proxy_redirect off;
root /opt/other;
index index.html;
}
但是当我转到 other.example.com 时,我得到的结果与 www.example.com 和 example.com
相同
有什么想法可以解决这个问题吗?
问题已解决。
我忘记用 .conf 扩展名命名 other.example.com 文件。
感谢@Curious
我的 nginx 上有三个文件 conf.d -
example.com
www.example.com
other.example.com
example.com 是我的首选域,是传递 nodejs 应用程序的代理。
example.com 具有以下配置
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:8081;
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;
}
}
www.example.com 具有以下配置:
server{
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
在其他example.com我有以下配置
server {
listen 80;
server_name other.example.com;
proxy_redirect off;
root /opt/other;
index index.html;
}
但是当我转到 other.example.com 时,我得到的结果与 www.example.com 和 example.com
相同有什么想法可以解决这个问题吗?
问题已解决。
我忘记用 .conf 扩展名命名 other.example.com 文件。
感谢@Curious