如何同时使用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
如何让ProxyPass和DirectoryIndex同时工作,或者其他配置的组合,这样当用户只点击
/时,它们就被路由到127.0.0.1:8080/static/index.html,而不仅仅是127.0.0.1:8080/static。
发布于 2016-10-13 20:51:28
问题是DirectoryIndex不会被使用,因为服务器已经匹配了ProxyPass /,因此它已经被传递给了另一个服务器。
您应该在后端服务器上设置DirectoryIndex。即8080端口上的那个。
发布于 2016-10-19 07:17:55
我已经测试了几种方法,而且到目前为止,您似乎希望我得到的唯一结果是使用mod_rewrite,如下所示:
RewriteEngine on
RewriteRule ^/$ http://127.0.0.1:8080/static/index.html [P,L]然后,您可以添加其余的:
RewriteRule ^/(.+) http://127.0.0.1:8080/static/$1 [P,L]这可能是一个很难做到的方法。
https://stackoverflow.com/questions/40027533
复制相似问题