【发布时间】:2021-05-03 00:07:07
【问题描述】:
目前我正在使用 nginx 服务器并使用 nodejs 服务器作为反向代理。 我想让 nginx 服务器 proxy_pass 按位置不同的服务器。
所以,假设我的域是subdomain.domain.com。
在加载subdomain.domain.com/ 时,它应该提供静态文件。
加载subdomain.domain.com/example1/req1/req2 时,应该路由到127.0.0.1:3000/req1/req2。
加载subdomain.domain.com/example2/req1/req2 时,应该路由到127.0.0.1:8080/req1/req2。
但我的配置将subdomain.domain.com/example1/req1/req2 路由到127.0.0.1:3000/example1/req1/req2 导致错误。 (nodejs返回Cannot GET /example1)
我应该如何正确编写这个 nginx conf 文件?
【问题讨论】:
-
nginx -t的任何结果? -
nginx -t 测试成功
-
如果其中一个答案解决了您的问题,请将其标记为这样,并在其左侧打勾!如果您自己或通过某种组合找到答案,您也可以回答自己的问题并在 2 天左右后标记!这增加了知识体系,可以帮助您在网站上获得声誉!
标签: nginx nginx-reverse-proxy nginx-config