情形:
OS centos
webserver apache http 2.2.23版
两个weblogic服务器集群
两个网络服务器
以上是硬件负载均衡器
基本上想要进行网址重定向和负载均衡(不修改会话)
当我输入agent.abconline.com时,它应该被重定向到应用服务器192.168.0.1:7001/agent staging.abconline.com应该被重定向到192.168.0.1; 7001 / staging
上面说过我可以单独使用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 :(得分:0)
您没有将相应的 / agent 和 / staging 上下文添加到反向代理规则中,并且显然会在退回的路上删除上下文,例如
RewriteRule / balancer://stagingcluster/staging%{REQUEST_URI} [P,QSA,L]
ProxyPassReverse / balancer://stagingcluster/staging
# Possibly also require a:
#ProxyHTMLURLMap balancer://stagingcluster/staging /