场景:
操作系统:CentOS
Web服务器:Apache http 版本 2.2.23
两个 WebLogic 服务器集群
两个 Web 服务器
以上内容均在硬件负载均衡器后面。
基本上想要对流量进行 URL 重定向和负载平衡(不修改会话)
当我输入 agent.abconline.com 时,应该被重定向到应用程序服务器 192.168.0.1:7001/agent;staging.abconline.com 应该被重定向到 192.168.0.1;7001/staging。
我可以仅使用 mod_rewrite 完成上述操作,但是在尝试使用 mod_proxy 和负载平衡时,无法将其重定向到所需的 URL。
以下是配置信息。
操作系统:CentOS
Web服务器:Apache http 版本 2.2.23
两个 WebLogic 服务器集群
两个 Web 服务器
以上内容均在硬件负载均衡器后面。
基本上想要对流量进行 URL 重定向和负载平衡(不修改会话)
当我输入 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>