如何同时使用 ProxyPass
和 DirectoryIndex
?
我有以下规则:
# Index
DirectoryIndex index.html
# Service Endpoint
ProxyPass /endpointA http://127.0.0.1:wxyz/
ProxyPassReverse /endpointA http://127.0.0.1:wxyz/
# Root Endpoint
ProxyPass / http://127.0.0.1:8080/static/
ProxyPassReverse / http://127.0.0.1:8080/static/
预期的行为是,当用户在 /
处点击机器时,应该为他们提供服务 127.0.0.1:8080/static/index.html
但是,我从 /static/
端点收到 404,因为它似乎没有试图加载的默认页面;如果我点击,这一切都可以正常工作
/index.html
将我路由到 127.0.0.1:8080/static/index.html
How can I have a ProxyPass and a DirectoryIndex working at the same time, or some other combination of configuration, so that when a user simply hits
/
, they are routed to127.0.0.1:8080/static/index.html
and not just127.0.0.1:8080/static
?
最佳答案
问题是 DirectoryIndex 不会被使用,因为服务器已经匹配了 ProxyPass/,所以它已经被传递给其他服务器。
您应该在后端服务器上设置 DirectoryIndex。即端口 8080 上的那个。
关于apache - 将 httpd ProxyPass 与 DirectoryIndex 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40027533/