简体   繁体   English

使用Apache HTTPD的负载均衡器

[英]Load Balancer with Apache HTTPD

I'm struggling to set up a an Apache httpd load balancer in front of a couple of application servers. 我正在努力在几个应用程序服务器之前设置一个Apache httpd负载平衡器。 This is my configuration: 这是我的配置:

ProxyRequests off

<Proxy balancer://mycluster>

    BalancerMember http://127.0.0.1:8080
    BalancerMember http://remote-svr:8080
    ProxySet lbmethod=bybusyness
    ProxySet stickysession=JESSIONIDSSO
</Proxy>

<Location /balancer-manager>
   SetHandler balancer-manager
</Location>

ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
ProxyPassReverseCookieDomain http://127.0.0.1:8080 localhost
ProxyPassReverseCookieDomain http://remote-svr:8080 localhost

I'm not sure the last 2 lines do anything, although one of the many examples I've looked at online used them, so I added them to see if it fixed my problem (it didn't). 我不确定最后两行是否有任何作用,尽管我在网上查看的许多示例之一都使用了它们,所以我添加了它们以查看它是否解决了我的问题(没有)。

The issue is that if I comment out either of the BalancerMember lines eg: 问题是,如果我注释掉BalancerMember中的任何一行,例如:

    #BalancerMember http://127.0.0.1:8080
    BalancerMember http://remote-svr:8080

Then the behaviour from a user perspective is fine, however when both members are active, the behaviour is wrong. 从用户的角度来看,行为就可以了,但是当两个成员都处于活动状态时,该行为是错误的。

The application initially displays a login screen, however when both load balancers are active, the user on submitting their username and password just get redirected back to the login screen again, maybe the session is being lost somewhere. 该应用程序最初显示一个登录屏幕,但是当两个负载平衡器均处于活动状态时,提交其用户名和密码的用户将再次被重定向回到登录屏幕,这可能是会话丢失了。 Does anyone have any idea what the issue might be? 有谁知道这个问题可能是什么?

EDIT - NOW WORKING 编辑-现在工作

for reference, this setup now seems to work: 供参考,此设置现在似乎可以使用:

ProxyRequests off
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

<Proxy balancer://mycluster>

    BalancerMember http://127.0.0.1:8080 route=localServer
    BalancerMember http://remote-svr:8080 route=remoteServer
    ProxySet lbmethod=bybusyness
    ProxySet stickysession=ROUTEID
</Proxy>

<Location /balancer-manager>
   SetHandler balancer-manager
</Location>

ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/ 

Note the 'route' attribute for the individual nodes needs to be set on the nodes themselves (server.xml in this case, as the servers run JBoss). 请注意,需要在节点本身上设置各个节点的“ route”属性(在这种情况下,由于服务器运行JBoss,因此为server.xml)。 JSESSIONID worked ok as the sticky session cookie for individual applications but there is more than one application on each server, and the user needs to use the same node for all. JSESSIONID可以作为单个应用程序的粘性会话cookie正常工作,但是每台服务器上都有多个应用程序,并且用户需要为所有应用程序使用同一节点。

If I were to guess you probably loose the session due to a typo in this section: 如果我猜想您可能由于本节中的错字而失去了会议时间:

<Proxy balancer://mycluster>
    BalancerMember http://127.0.0.1:8080
    BalancerMember http://remote-svr:8080
    ProxySet lbmethod=bybusyness
    ProxySet stickysession=JESSIONIDSSO
</Proxy>

ProxySet stickysession=JESSIONIDSSO this should probably say ProxySet stickysession=JSESSIONIDSSO ? ProxySet stickysession=JESSIONIDSSO这可能应该说ProxySet stickysession=JSESSIONIDSSO Or maybe even JSESSIONID ? 甚至是JSESSIONID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM