使用Nginx代理将子域指向节点表示自定义路由

时间:2019-04-01 13:24:05

标签: express nginx

我有一个配置了nginx代理的域,可以像这样路由:   mydomain.com->本地主机:3000 但是现在,我希望一个特定的子域指向如下所示的内容:   subdomain.mydomain.com->本地主机:3000 / mypage 尝试了几件事,但我无法使它起作用: 服务器{   听80;   server_name subdomain.mydomain.com;   server_tokens关闭;   proxy_hide_header X-Powered-By;   位置/健康检查{     access_log关闭;     proxy_pass http:// localhost:3000;     proxy_set_header升级$ http_upgrade;     proxy_set_header连接“升级”;     proxy_set_header主机$ host;     proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;     proxy_cache_bypass $ http_upgrade;   }   #NGINX将拒绝任何不匹配的内容/   位置〜/(?
.+)/ {     #使用不支持的HTTP方法拒绝请求     if($ request_method!〜^(GET | POST | HEAD | OPTIONS | PUT | DELETE)$){       返回405;     }     #只有符合白名单期望的请求才会     #发送到应用服务器     proxy_pass http:// localhost:3000 / mypage / $ section;     proxy_set_header升级$ http_upgrade;     proxy_set_header连接“升级”;     proxy_set_header主机$ host;     proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;     proxy_cache_bypass $ http_upgrade;  } }

0 个答案:

没有答案
相关问题