Apache 将httpd ProxyPass与DirectoryIndex一起使用

Apache 将httpd ProxyPass与DirectoryIndex一起使用,apache,url-rewriting,httpd.conf,proxypass,Apache,Url Rewriting,Httpd.conf,Proxypass,如何同时使用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/ Pro

如何同时使用
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


问题是不会使用DirectoryIndex,因为服务器已与ProxyPass/匹配,因此它已被传递到另一台服务器


您应该在后端服务器上设置DirectoryIndex。i、 e.端口8080上的一个。

我已经测试了几种方法,到目前为止,唯一一个产生您想要的结果的方法似乎是使用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]

这可能是一个粗略的方法。

您的答案可能会导致混淆。正在使用DirectoryIndex,index.html是本地的还是远程的没有区别。是否在备份服务器上使用DirectoryIndex?否则,对/上backbend服务器的请求将失败。是的,op已经说过了这一部分,我添加了一个新的答案,建议他可以做些什么来避免/index.html被反向代理。它在哪里说明了后端服务器的DirectoryIndex?我非常抱歉,似乎我缺少足够的咖啡,误读了整件事。在阅读和一些测试之后,我修正了我的回复。谢谢你的耐心!这并不能回答问题。用户希望index.html被代理。wops,你完全正确,我误读了,请允许我修复它。顺便说一句,我还支持@DanielScott的回答,他在回答中告诉你在后端本身使用这样的重定向或索引引用,因为你无论如何都要放弃/到后端。在这种情况下,我发现从前端控制它的唯一方法是mod_rewrite,或者至少在我的测试中,它是唯一优先于proxypass的方法