命名空间 URL 使用反向代理 (Apache)

Namespace URL Using Reverse Proxy (Apache)

我有一堆相同的应用程序,它们配置为侦听相同的 url 路径。例如:

http://server:80/app

我想设置一个 Apache 反向代理来为 URL 提供命名空间,这样每个应用程序就不会有冲突的 URL:

http://proxy:80/namespace1/app -> http://destserver1:80/app
http://proxy:80/namespace2/app -> http://destserver2:80/app

我试过 ProxyPass、ReverseProxyPass 和 ProxyPreserveHost 选项都无济于事。特别是当应用发送重定向请求时,重定向不会保留命名空间。

在充当反向代理时应用命名空间功能的示例 httpd 配置文件是什么样的?

这是我的示例配置(针对单个服务器),它不适用于重定向:

Listen 80

<VirtualHost *:80>

ServerName 127.0.0.1:80

<Location /namespace/app/>
    ProxyPreserveHost on
    ProxyPass http://destserver:80/app/
    ProxyPassReverse http://destserver:80/app/
</Location>

#ErrorLog logs/test-log
</VirtualHost>

问题是 http://proxy:80/namespace/app/path 发送的重定向变为 http://proxy:80/app/path/redirect/path (404),缺少命名空间。

谢谢

本教程提供了我的确切用例的答案:http://www.apachetutor.org/admin/reverseproxies

我复制了下面的重要片段:

The fundamental configuration directive to set up a reverse proxy is 
ProxyPass. We use it to set up proxy rules for each of the application servers:


ProxyPass       /app1/  http://internal1.example.com/
ProxyPass       /app2/  http://internal2.example.com/

...

The command to enable such rewrites in the HTTP Headers is ProxyPassReverse. 
The Apache documentation suggests the form:


ProxyPassReverse /app1/ http://internal1.example.com/
ProxyPassReverse /app2/ http://internal2.example.com/
However, there is a slightly more complex alternative form that I recommend
as more robust:


<Location /app1/>
    ProxyPassReverse /
</Location>
<Location /app2/>
    ProxyPassReverse /
</Location>