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:
- From PC1, if I browse to localhost, I see Apache HTTP server home page
- From PC1, if I browse to localhost/jkstatus, I see the JK Status manager page
- From PC1, if I browse to localhost:8080, I see the tomcat home page
- From PC1, if I browse to localhost/examples, I see the tomcat examples page
- From PC1, if I browse to PC2.ipaddres:8080, I see the tomcat home page
- From PC2, if I browse to PC1.ipaddres/jkstatus, I see the JK status manager page
- From PC2, if I browse to PC1.ipaddres:8080, I see the tomcat home page
- 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:
- Apache http server: httpd-2.4.46-win64-VS16 (https://www.apachelounge.com/download/)
- Tomcat: apache-tomcat-9.0.41-windows-x64
- Tomcat connector (mod_jk): mod_jk-1.2.48-win64-VS16 (https://www.apachelounge.com/download/)
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
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
workers.properties
Could you please use below configuration in worker.properties.
Mod_JK: