首页 > 解决方案 > 仅当我使用“/”(不在其他路径中)时,Apache ProxyPass 才加载资源

问题描述

我正在尝试使用 Apache 将 React 加载到另一个端口。我在 Apache Config 文件中使用:

ProxyPass /node http://localhost:3000/

这显示了我的 index.html,但不是我的 React 资源(图像、js ...)(在localhost/node中)

我发现了这个,如果我更改它的工作目录(在localhost/中):

ProxyPass / http://localhost:3000/

但我不想使用我的“/”,因为我想组合两个按时工作的端口,在另一个站点中显示一个站点。

¿如何在localhost/node中正确加载我的端口 3000 ?

先感谢您!!

标签: node.jslinuxreactjsapacheproxy

解决方案


来自 mod_proxy 文档: https ://httpd.apache.org/docs/2.4/mod/mod_proxy.html

添加 ProxyPassReverse 指令和引号:

ProxyPass "/foo" " http://foo.example.com/bar "

ProxyPassReverse "/foo" " http://foo.example.com/bar "


推荐阅读