[英]How to retrieve request URI in Apache virtual host configuration file on Redhat?
I have created a Httpd Virtual host configuration file under /etc/httpd/conf.d
to load balance between 2 servers. 我在/etc/httpd/conf.d
下创建了一个Httpd虚拟主机配置文件,以在2台服务器之间实现负载平衡。 My configuration looks something like this: 我的配置如下所示:
<VirtualHost *:8086>
ProxyRequests off
ServerName domain.com
<Proxy balancer://mycluster>
BalancerMember http://example1.com/b
BalancerMember http://example2.com/b
Allow from all
ProxySet lbmethod=byrequests
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
ProxyPass /balancer-manager !
ProxyPass /a/b balancer://mycluster/
</VirtualHost>
If you see the above configuration, I am accessing my load balancer at the URL, domain.com:8086/a/b
. 如果您看到上述配置,则说明我正在通过URL domain.com:8086/a/b
访问负载均衡器。 My requirement is that when the request comes as domain.com:8086/a/b/c/d
where c,d are dynamic values, I want to append them to my BalancerMembers. 我的要求是,当请求以domain.com:8086/a/b/c/d
出现时,其中c,d是动态值,我想将它们附加到我的BalancerMembers中。 ie It has to load balance between http://example1.com/b/c/d
and http://example2.com/b/c/d
. 即,它必须在http://example1.com/b/c/d
和http://example2.com/b/c/d
之间进行负载平衡。 How do I do this? 我该怎么做呢?
Always match slashes with the target: 始终将斜杠与目标匹配:
ProxyPass /a/b/ balancer://mycluster/
If the target is balancer://mycluster you always need to add a trailing slash because it is really balancer://mycluster/ and if that is your target you need to add a trailing slash in the origin too, therefore ProxyPass /a/b/ . 如果目标是balancer:// mycluster,则始终需要添加尾部斜杠,因为它实际上是balancer:// mycluster /,如果这是您的目标,则也需要在原点中添加尾部斜杠,因此ProxyPass / a / b /。 If you don't, you will have issues sening incorrect uri to the backend. 如果您不这样做,则会遇到将不正确的uri分配到后端的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.