I have a two CentOS 8 nodes (192.168.1.101 and 192.168.1.102) in cluster (using pacemaker) where I configured VIP (192.168.1.100) and Apache as cluster's resources. On all nodes are installed Apache 2.4 and Tomcat 9
The configuration for Apache is: vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ProxyPreserveHost On
<Proxy balancer://myClusterBalancer>
BalancerMember http://192.168.1.101:8080/ route=server01 keepalive=On ping=5 max=200 ttl=120
BalancerMember http://192.168.1.102:8080/ route=server02 keepalive=On ping=5 max=200 ttl=120
ProxySet stickysession=JSESSIONID|jsessionid lbmethod=byrequests timeout=60
</Proxy>
ProxyPass /server-status !
ProxyPass /MyWebApp/ balancer://myClusterBalancer/MyWebApp/ stickysession=JSESSIONID|jsessionid scolonpathdelim=On
ProxyPassReverse /MyWebApp/ balancer://myClusterBalancer/MyWebApp/
ProxyPass / balancer://myClusterBalancer/MikiFax/ stickysession=JSESSIONID|jsessionid scolonpathdelim=On
ProxyPassReverse / balancer://myClusterBalancer/MyWebApp/
</VirtualHost>
and my Tomcat server.xml for Node1 and Node2 vim /opt/tomcat/conf/server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="server01">
<Engine name="Catalina" defaultHost="localhost" jvmRoute="server02">
My system work in this way:
- HTTP request to VIP on http://192.168.1.100/MyWebApp and I receive a reply from Apace;
- Apace forward the request to one of the two Tomcat as Reverse Proxy and Load Balancer
- Tomcat send http response
Now on the page on Tomcat I have different link and I need when I click on this link (open a new tab) I must use the same Tomcat Server.
The link are in this format:
First Link:
<a target="_blank" href="http://192.168.1.100/MyWebApp/F?URL=1599825050056&viewAttach=Y">CLICK FOR DETAILS</a>
When I click it I open a new tab with this Second Link:
<a href="attachments\myAttachment.pdf" target="_blank">myAttachment.pdf</a>
this file is saved on the server when I load the page (after I click on the first link), and If I click on the link I open the file in new tab, but sometime this request is processed by the other server and I receive an error because on the second server this file was not downloaded.
How can I resolve this problem? Thanks for the update.
I Solved it.
Modify Tomcat server.xml for Server1
Modify Tomcat server.xml for Server2
Modify Apache conf