问题描述
我试图将我的apache服务器配置为代理,以服务于两个内部服务,一个监听8080,并且应该接收特定URL上的流量,另一个监听8077,并且应该接收所有其他http流量
i am trying to configure my apache server as proxy to serve two internal services , one listening on 8080 and should receive traffic on specific URL and the other listening on 8077 and should receive all other http traffic
我在运行这两个服务的同一台服务器上部署并配置了Apache,它正在侦听443和所有SSL配置,并且运行正常
I deployed and configured apache on the same server where these two services running and it is listening to 443 along with all SSL configuration and it is working fine
我还启用了proxy_module,proxy_http_module和proxy_http2_module
also I enabled the proxy_module, proxy_http_module and proxy_http2_module
我要实现的目标
如果请求的URL是/webhook1->将其传递给EP1 http://localhost:8080 并任何其他请求的URL应该传递给EP2 http://localhost:8077
if the requested URL is /webhook1 --> pass it to EP1 http://localhost:8080 andany other requested URL should be passed to EP2 http://localhost:8077
我对第一个服务的当前配置
My Current Configuration towards the first service
ProxyPass /webhook1 http://localhost:8080
ProxyPassReverse /webhook1 http://localhost:8080
现在我想定义另一个代理通过类似
Now I want to define another proxy pass to be something like
ProxyPass / http://localhost:8077
ProxyPassReverse / http://localhost:8077
无法同时使用这两种配置,感谢您在如何配置apache以达到我的要求方面的帮助
putting both configuration together is not working , appreciate your help in how to configure apache to achieve my requirement
提前谢谢
推荐答案
按要求的正确顺序放置ProxyPass规则
Put the ProxyPass rules in the correct order as required
如果要评估/webhook1规则并将其发送到8080,否则将流量发送到8077,则规则应遵循以下顺序
if you want to evaluate /webhook1 rule and send it to 8080, else send the traffic to 8077 the rules should be on the following order
ProxyPass /webhook1 http://localhost:8080
ProxyPassReverse /webhook1 http://localhost:8080
ProxyPass / http://localhost:8077
ProxyPassReverse / http://localhost:8077
这篇关于使用多个ProxyPass配置Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!