2012-12-03 131 views
2

場景:
OS的CentOS
Web服務器的Apache HTTP版本2.2.23
兩個WebLogic服務器集羣
兩個Web服務器apache httpd的mod_proxy的負載與多個虛擬主機URL重定向平衡

以上是後面的硬件負載平衡器

基本上想做網址重定向和負載均衡(不修改會話)的流量

當我輸入agent.abconline.com應該重定向到應用服務器192.168.0.1:7001/agent staging.abconline.com應該重定向到192.168.0.1; 7001 /分期

上面說的我能做單獨的mod_rewrite,但同時用的mod_proxy和負載均衡努力,我下面是不能夠重定向到該URL

是配置

NameVirtualHost *:80 
<VirtualHost *:80> 
     ServerName agent.abconline.com 
     RewriteEngine On 

     <Proxy balancer://agentcluster> 
     BalancerMember http://192.168.0.1:7003 route=1 loadfactor=50 retry=60 
     BalancerMember http://192.168.0.2:7003 route=1 loadfactor=50 retry=60 
     </Proxy> 

     # Redirect all non-static requests to agent 
     RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
     RewriteRule ^/(.*)$ balancer://agentcluster%{REQUEST_URI} [P,QSA,L] 

     ProxyPass /abc-oper balancer://agentcluster/abc-oper 
     ProxyPassReverse /abc-oper balancer://agentcluster/abc-oper 
     ProxyPreserveHost on 

     SetEnv force-proxy-request-1.0 1 
     SetEnv proxy-nokeepalive 1 

     <Proxy *> 
     Order deny,allow 
     Allow from all 
     </Proxy> 

     ErrorLog /apps/apache/logs/agent.abconline.com.error.log 
     CustomLog /apps/apache/logs/agent.abconline.com.access.log combined 
     LogLevel debug 
</VirtualHost> 

<VirtualHost *:80> 
     ServerName staging.abconline.com 
     RewriteEngine On 

     <Proxy balancer://stagingcluster> 
     BalancerMember http://192.168.0.1:7003 route=1 loadfactor=50 retry=60 
     BalancerMember http://192.168.0.2:7003 route=1 loadfactor=50 retry=60 
     </Proxy> 

     # Redirect all non-static requests to agent 
     RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
     RewriteRule ^/(.*)$ balancer://stagingcluster%{REQUEST_URI} [P,QSA,L] 

     ProxyPass /abc-oper balancer://stagingcluster/abc-oper 
     ProxyPassReverse /abc-oper balancer://stagingcluster/abc-oper 
     ProxyPreserveHost on 

     SetEnv force-proxy-request-1.0 1 
     SetEnv proxy-nokeepalive 1 

     <Proxy *> 
     Order deny,allow 
     Allow from all 
     </Proxy> 

     ErrorLog /apps/apache/logs/staging.abconline.com.error.log 
     CustomLog /apps/apache/logs/staging.abconline.com.access.log combined 
     LogLevel debug 
</VirtualHost> 

回答

0

你不添加適當的/劑/分期上下文與反向代理規則相關聯,並且在返回時明顯移除上下文。

RewriteRule /balancer://stagingcluster/staging%{REQUEST_URI} [P,QSA,L] 
ProxyPassReverse/balancer://stagingcluster/staging 


# Possibly also require a: 
#ProxyHTMLURLMap balancer://stagingcluster/staging /