apache - 将 httpd ProxyPass 与 DirectoryIndex 结合使用

标签 apache url-rewriting httpd.conf proxypass

如何同时使用 ProxyPassDirectoryIndex

我有以下规则:

# 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 to 127.0.0.1:8080/static/index.html and not just 127.0.0.1:8080/static?

最佳答案

问题是 DirectoryIndex 不会被使用,因为服务器已经匹配了 ProxyPass/,所以它已经被传递给其他服务器。

您应该在后端服务器上设置 DirectoryIndex。即端口 8080 上的那个。

关于apache - 将 httpd ProxyPass 与 DirectoryIndex 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40027533/

相关文章:

Apache 配置单元错误 Merging of credentials not supported in this version of hadoop

传递查询字符串时,.htaccess 会破坏 CSS 和 Javascript

eclipse - 如何在 tomcat 服务器中更改我的 webapp 的 url?

apache - Docker Apache 安装失败

apache - 出现 (13)Permission returned: make_sock: Could not bind to address [::]:9000 错误的原因是什么?

php - 如何在网页的标题中获取内容长度或 CRC?

regex - 了解 RewriteCond 中的 THE_REQUEST 变量

url-rewriting - nginx 子域重写

php - 在 apache 网络服务器上使用 Ratchet websocket 库为安全 websocket 配置虚拟主机

apache - 让 Apache 允许通过 HTTPS 访问 Express API