gpt4 book ai didi

linux - Apache 多端口绑定(bind)

转载 作者:太空宇宙 更新时间:2023-11-04 13:04:02 25 4
gpt4 key购买 nike

我已经在 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>

最佳答案

我找到了答案,下面是最终的解决方案,

<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>

关于linux - Apache 多端口绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33207405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com