如何使用apache将两条不同的路径路由到同一台服务器
How to route two different paths to the same server using apache
考虑两个 url:
- www.mysite.com/*
- www.mysite.com/browse/*
运行
我如何确保所有具有以下模式的请求都将像下面这样在我的后端结束?
示例:
www.mysite.com/doA --> localhost:8080/doA
www.mysite.com/browse/doA --> localhost:8080/doA
所以基本上 www.mysite.com/doA 和 www.mysite.com/browse/doA 结果相同。
我想使用apache 服务器。我可以使用 proxy_http 重定向一个。但它不适用于两个或更多 urls:
这是我的配置,适用于一个 url
<VirtualHost *:80>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ProxyRequests Off
<Proxy http://localhost:8080/*>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
这应该有效:
<VirtualHost *:80>
ServerName example.com
ProxyRequests Off
ProxyPass /browse/ http://localhost:8080/
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
The configured ProxyPass
and ProxyPassMatch
rules are checked in
the order of configuration. The first rule that matches wins. So
usually you should sort conflicting ProxyPass
rules starting with
the longest URLs first. Otherwise, later rules for longer URLS will be
hidden by any earlier rule which uses a leading substring of the URL
考虑两个 url:
- www.mysite.com/*
- www.mysite.com/browse/*
我如何确保所有具有以下模式的请求都将像下面这样在我的后端结束?
示例:
www.mysite.com/doA --> localhost:8080/doA
www.mysite.com/browse/doA --> localhost:8080/doA
所以基本上 www.mysite.com/doA 和 www.mysite.com/browse/doA 结果相同。
我想使用apache 服务器。我可以使用 proxy_http 重定向一个。但它不适用于两个或更多 urls:
这是我的配置,适用于一个 url
<VirtualHost *:80>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ProxyRequests Off
<Proxy http://localhost:8080/*>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
这应该有效:
<VirtualHost *:80>
ServerName example.com
ProxyRequests Off
ProxyPass /browse/ http://localhost:8080/
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
The configured
ProxyPass
andProxyPassMatch
rules are checked in the order of configuration. The first rule that matches wins. So usually you should sort conflictingProxyPass
rules starting with the longest URLs first. Otherwise, later rules for longer URLS will be hidden by any earlier rule which uses a leading substring of the URL