【发布时间】:2020-03-18 10:56:59
【问题描述】:
大家好
我试图在 Digital Ocean 上部署我的 nodejs api,在子域 https://api.host.com 下。它有一些路径波纹管,都从 /v0.1 开始。
在这个 droplet 上,nodejs 应用程序正在 http://localhost:3000 上运行
在同一个 droplet 上,我有其他应用程序,一个托管在 Apache 上的网站,并在 https://host.com 回复它工作正常。
我使用 Apache 进行反向代理,从 https://api.host.com/ 到 http://localhost:3000 进行所有调用。
实际上它只适用于根路径,我的意思是尝试访问https://api.host.com/ 响应正确但是当我尝试访问其他路径时出现错误
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request
Reason: DNS lookup failure for: 127.0.0.1:3000v0.1
Apache/2.4.29 (Ubuntu) Server at api.host.com Port 443
HTTP 状态码:502 代理错误
我的虚拟主机看起来像...
<VirtualHost *:80>
...
...
ServerName api.host.com
ProxyPass /.well-unknown/ !
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
...
...
</VirtualHost>
请帮忙!
【问题讨论】:
标签: node.js apache reverse-proxy