nginx - nginx 只接受子域名

标签 nginx reverse-proxy

我在 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/

相关文章:

azure - <allowedServerVariables> 标记应位于 Azure 网站 applicationHost.config 中的什么位置?

python - 使用 Google App Engine 标准环境时将 "/blog"转发到 WordPress 安装

html - XMLHttpRequest 无法加载 http ://localhost:9090/receive. 请求的资源上不存在 'Access-Control-Allow-Origin' header

node.js - 连接上游时出错。 Docker 撰写,NodeJS,Nginx

docker - 使用 nginx 作为反向代理时连接到上游时连接被拒绝

java - 限制 Varnish 客户端等待时间,而不是后端时间

nginx - 查看所有 nginx 变量

php - Nginx 在下载时损坏文件

iis-7 - HTTP 错误 500.52 - URL 重写模块错误。

apache - centos 7上Nginx反向代理apache,同时配置http和https