3

I am trying to set up mod_proxy_balancer for routing requests to 2 jboss7-servers. For the time being I am testing this setup on my local machine, using following config in httpd.conf:

ProxyRequests Off
<Proxy \*>
   Order deny,allow
   Deny from all
</Proxy>

ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid scolonpathdelim=On
<Proxy balancer://mycluster>
BalancerMember http://localhost:8080 route=node1
BalancerMember http://localhost:8081 route=node2    
Order allow,deny
Allow from all
</Proxy>

and in the standalone.xml file of each jboss I have defined the jvmRoute system property:

<system-properties>
    <property name="jvmRoute" value="node1"/>  
</system-properties>

At http:// localhost/myapp the application is accessible but the java-session is not build up correctly. Consequently the authentication is not working.

The funny thing is, that everything is working if I turn off one JBoss-instance.

As I have tried a couple of settings already, I am thankful for any further suggestions.

Phil P.
  • 51
  • 1
  • 5
  • It seems that the request is always routed to another jboss-instance. jboss consequently always adds the Set-Cookie field with a new JSESSIONID cookie. – Phil P. Dec 02 '13 at 22:31

3 Answers3

2

I finally got the config to work.

I had to to add following settings in the JBoss7 config (standalone.xml):

<system-properties>
<property name="jvmRoute" value="node1"/>
<property name="UseJK" value="true"/>
</system-properties>

and:

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" **instance-id="node1" native="false">

...

Phil P.
  • 51
  • 1
  • 5
0

The above settings will work for standalone instances, but for domain configurations you need to add the "jvmRoute" to the host.xml under the servers section

<server name="server-one" group="server-one-group" auto-start="true">
  <system-properties>
  <property name="jvmRoute" value="server1" boot-time="true"/>
  </system-properties>
</server>

Repeat the same for all your nodes

<server name="server-one" group="server-one-group" auto-start="true">
  <system-properties>
  <property name="jvmRoute" value="server2" boot-time="true"/>
  </system-properties>
</server>

If you are using mod_jk to loadbalance between your nodes then on the webserver you need to define your nodes with the jvmRoute that you configured above as follows: worker.properties file contains:

worker.list=oblb
worker.oblb.type=lb
worker.oblb.balance_workers=server1,server2
worker.oblb.sticky_session=true
worker.server1.reference=worker.template
worker.server1.host=Appserverhost1.example.com
worker.server1.port=8009

worker.server2.reference=worker.template
worker.server2.host=Appserverhost2.example.com
worker.server2.port=8009

worker.template.type=ajp13
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
Gayam
  • 1
0

Please try this : it worked for me Another example of how to provide load balancing with stickyness using mod_headers, even if the back-end server does not set a suitable session cookie:

Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED BalancerMember "http://192.168.1.50:80" route=1 BalancerMember "http://192.168.1.51:80" route=2 ProxySet stickysession=ROUTEID ProxyPass "/test" "balancer://mycluster" ProxyPassReverse "/test" "balancer://mycluster"

For more details please refer the below httpd documentation : https://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html