skip to Main Content

I setup a simple load balancer with the following configuration

  • PC0 (win10) is my actual pc that is running VirtualBox with two PC’s (PC1 and PC2)
  • PC1 (win10) is running an Apache HTTP server with mod_jk load balancer and a tomcat application server
  • PC2 (win10) is running a tomcat application server

The load balancer and tomcat server are working:

  1. From PC1, if I browse to localhost, I see Apache HTTP server home page
  2. From PC1, if I browse to localhost/jkstatus, I see the JK Status manager page
  3. From PC1, if I browse to localhost:8080, I see the tomcat home page
  4. From PC1, if I browse to localhost/examples, I see the tomcat examples page
  5. From PC1, if I browse to PC2.ipaddres:8080, I see the tomcat home page
  6. From PC2, if I browse to PC1.ipaddres/jkstatus, I see the JK status manager page
  7. From PC2, if I browse to PC1.ipaddres:8080, I see the tomcat home page
  8. From PC2, if I browse to PC1.ipaddres/examples, I see the tomcat examples page

That all seems to work. Now if I close the tomcat application server on PC1, then 4 and 8 are not working anymore: It throws a 503 Service Unavailable page. It seems that the load balancer isn’t able to redirect to PC2. Indeed, the JK status manager page shows that PC2 is in state ERR/REC (PC too, but that is because I shutdown Tomcat on that PC).

I didn’t see anything suspicious in the logs.

Next, I thought it had to be something with the firewall (blocking port 8009), so I disabled the firewall on all PC’s (PC0, PC1 and PC2). But that didn’t help. I assume this excludes the firewall from blocking anything?

I still suspect anything from blocking the connection…

Any suggestions?

My versions:

My configs:

Apache/conf/httpd.conf, added to the bottom:

# Load mod_jk module 
LoadModule jk_module modules/mod_jk.so 
<IfModule jk_module>
JkWorkersFile conf/workers.properties 
JkLogFile logs/mod_jk.log 
JkLogLevel info 
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" 
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories 
JkMount /examples balancer 
JkMount /examples/* balancer 
JkMount /jkstatus jkstatus 
</IfModule>

Apache/conf/workers.properties:

worker.list=jkstatus, balancer 
Declare Tomcat server worker1 
worker.worker1.type=ajp13 
worker.worker1.host=localhost
worker.worker1.port=8009 
worker.worker2.type=ajp13 
worker.worker2.host=10.160.85.122
worker.worker2.port=8009 
worker.balancer.type=lb 
worker.balancer.balance_workers=worker1,worker2 
worker.jkstatus.type=status 

Tomcat/conf/server.xml, added:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" secretRequired="false"/> 
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">

(On PC2 jvmRoute="worker2")

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for your reply. Unfortunately it didn't solve the issue. The problem remains unchanged.

    I also tried to make the situation somewhat easier. I moved the HTTP server to PC0 and only run a tomcat server on PC1. Again the problem is unchanged. I still receive a 503 error.

    httpd.conf

    LoadModule jk_module modules/mod_jk.so 
    <IfModule jk_module>
    JkWorkersFile conf/workers.properties 
    JkLogFile logs/mod_jk.log 
    JkLogLevel info 
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" 
    JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories 
    JkMount /examples worker1
    JkMount /examples/* worker1
    </IfModule>
    

    workers.properties

    worker.list=worker1
    worker.worker1.type=ajp13
    worker.worker1.host=10.160.85.252
    worker.worker1.port=8009
    

  2. Could you please use below configuration in worker.properties.

    worker.list=loadbalancer,status
    worker.template.port=8009
    worker.template.type=ajp13
    worker.template.ping_mode=A
    worker.template.socket_connect_timeout=10000
    worker.worker1.reference=worker.template
    worker.worker1.host=127.0.0.1
    worker.worker2.reference=worker.template
    worker.worker2.host=10.160.85.122
    worker.loadbalancer.balance_workers=worker1,worker2
    worker.loadbalancer.type=lb
    worker.loadbalancer.sticky_session=True
    worker.status.type=status
    

    Mod_JK:

    JkMount /* loadbalancer
    JkMount /jkstatus status 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search