使用Apache HTTP Server,如何对所有URL进行负载均衡,而不仅仅是root“/”或根目录下的某些子目录,如“/ css”,但绝对是平衡后端的所有内容?
我的配置只会路由文字根URL“/”,但其他网址不包括在内,我是否需要使用正则表达式?
相关配置:
<Proxy balancer://mycluster>
BalancerMember https://server1:8443
BalancerMember https://server2:8443
ProxySet lbmethod=byrequests
</Proxy>
<VirtualHost _default_:443>
SSLProxyEngine on
ProxyPass "/" "balancer://mycluster"
ProxyPassReverse "/" "balancer://mycluster"
</VirtualHost>
Apache access_log(通知/ css收到500响应):
172.18.0.1 - - [10/May/2017:20:22:55 +0000] "GET / HTTP/1.1" 200 196
172.18.0.1 - - [10/May/2017:20:22:58 +0000] "GET /css HTTP/1.1" 500 528
Apache error_log:
[Wed May 10 20:22:58.607433 2017] [proxy:warn] [pid 9:tid 140682836559616] [client 172.18.0.1:35304] AH01144: No protocol handler was valid for the URL /css. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
答案 0 :(得分:2)
ProxyPass / ....足以代理所有内容,但请确保匹配斜杠,指定“balancer:// mycluster”不正确,并且您需要来回匹配斜杠,因此如果您的原点以斜线结尾目标也以斜线结束,加上在这种情况下balancer:// mycluster真的是平衡器:// mycluster /
ProxyPass / balancer://mycluster/