我在 nginx 中为 node.js 服务器设置了反向代理。
server {
listen 80;
server_name sub.domain.tld;
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;
}
}
一切正常,花花公子,但是,我只希望 sub.domain.tld
工作。在浏览器中打开 domain.tld
仍然会路由到 node.js 服务器。
最佳答案
尝试添加这个
server {
listen 80;
server_name domain.tld;
return 404;
}
关于nginx - nginx 只接受子域名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23441711/