我已经在apache中配置了我的httpd.conf,根据请求的端口号指向多个站点。在Windows中部署时,此配置工作正常,但当我将相同的配置移动到Linux时,它不起作用,请协助。
以下是相同的代码段。
Listen 81
Listen 82
<VirtualHost *:81>
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule ^((?!/services).)*$ http://%{HTTP_HOST}%{REQUEST_URI}
ServerAdmin root@localhost
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
ProxyPass / balancer://mycluster/ stickysession=ROUTEID
<Proxy balancer://mycluster>
Order deny,allow
Allow from all
BalancerMember http://10.236.75.102:9765 route=AS1 loadfactor=100 timeout=600 Keepalive=On
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order deny,allow
Allow from all
<IfModule mod_headers.c>
SetEnvIf Origin (.*) AccessControlAllowOrigin=$1
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials true
</IfModule>
</Location>
</VirtualHost>
<VirtualHost *:82>
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule ^((?!/services).)*$ http://%{HTTP_HOST}%{REQUEST_URI}
ServerAdmin root@localhost
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
ProxyPass / balancer://mycluster/ stickysession=ROUTEID
<Proxy balancer://mycluster>
Order deny,allow
Allow from all
BalancerMember http://10.236.75.101:9767/carbon/ route=UES1 loadfactor=100 timeout=600 Keepalive=On
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order deny,allow
Allow from all
<IfModule mod_headers.c>
SetEnvIf Origin (.*) AccessControlAllowOrigin=$1
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials true
</IfModule>
答案 0 :(得分:0)
我找到了答案,下面是最终解决方案,
<VirtualHost *:81>
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule ^((?!/services).)*$ http://%{HTTP_HOST}%{REQUEST_URI}
ServerAdmin root@localhost
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
ProxyPass / balancer://mycluster/ stickysession=ROUTEID
<Proxy balancer://mycluster>
Order deny,allow
Allow from all
BalancerMember http://10.236.75.102:9765 route=AS1 loadfactor=100 timeout=600 Keepalive=On
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order deny,allow
Allow from all
<IfModule mod_headers.c>
SetEnvIf Origin (.*) AccessControlAllowOrigin=$1
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials true
</IfModule>
</Location>
</VirtualHost>
<VirtualHost *:82>
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule ^((?!/services).)*$ http://%{HTTP_HOST}%{REQUEST_URI}
ServerAdmin root@localhost
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
ProxyPass / balancer://mycluster1/ stickysession=ROUTEID
<Proxy balancer://mycluster1>
Order deny,allow
Allow from all
BalancerMember http://10.236.75.101:9767/carbon route=UES1 loadfactor=100 timeout=600 Keepalive=On
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order deny,allow
Allow from all
<IfModule mod_headers.c>
SetEnvIf Origin (.*) AccessControlAllowOrigin=$1
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials true
</IfModule>
</Location>
</VirtualHost>
httpd-ssl.conf
中也需要类似的配置Virtualhost应该有多个条目,如:
<VirtualHost *:446>
.......
ProxyPreserveHost On
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
ProxyPass / balancer://mycluster1/ stickysession=ROUTEID
<Proxy balancer://mycluster1>
Order deny,allow
Allow from all
BalancerMember http://10.236.75.101:9767/carbon route=UES1 loadfactor=100 timeout=600 Keepalive=On
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Order deny,allow
allow from all
SSLRequireSSL
</Location>