2017-05-10 83 views
0

使用Apache HTTP Server,我如何負載均衡所有的URL,不僅僅是root /「/」或像「/ css」這樣的根目錄下的一些子目錄,但絕對是平衡後端的一切?Apache ProxyPass負載平衡所有URL的

我的配置只會路由文字根URL「/」但其他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. 

回答

1

的ProxyPass/....是足以代理所有內容,但要確保匹配斜槓,指定「balancer:// mycluster」不正確,並且您需要ma TCH斜線來回,所以如果你的原產地在斜線結束的目標也結束斜槓,加上在這種情況下平衡器:// myCluster中真的平衡器:// myCluster中/

ProxyPass/balancer://mycluster/ 
+0

奇,我是有這樣的之前,它沒有工作。現在呢!謝謝 – szxnyc