0

We are looking at moving from Websphere to Tomcat. I'm trying to send traffic to tomcat from apache web server based on the virtual host directives in apache web server.

After some playing around I have it sort of working, but I'm noticing that if I have a JKMount directive in the first VirtualHost in apache, all virtualHosts will send to the application server. If I have the JKMount in Virtual hosts further down in the configs, then only that VirtualHost works with the request.

For Example, with the configs below here are my symptoms

mysite.com/Webapp1/ --> I resolve to the proper application mysite2.com/Webapp1/ --> I resolve to the proper application (bad!) mysite.com/MonitorApp/ --> I resolve to the proper application mysite2.com/MonitorApp/ --> I resolve to the proper application (bad!) mysite.com/Webapp2/ --> I DO NOT get to the app (good) mysite2.com/Webapp2/ --> I resolve to the proper application

Here's what my web server virtualhosts look like.

<VirtualHost 255.255.255.1:80>
    ServerName mysite.com
    ServerAlias aliasmysite.ca
##all our rewrite rules
JkMount /Webapp1/* LoadBalanceWorker
JKmount /MonitorApp/* LoadBalanceWorker
</VirtualHost>


<VirtualHost 255.255.255.2:80>
    ServerName mysite2.com
    ServerAlias aliasmysite2.ca
##all our rewrite rules
JkMount /Webapp2/* LoadBalanceWorker
</VirtualHost>

we are running apache webserver 2.2.10 and tomcat 7.0.29 on Solaris10

I've posted an image of our architecture here. http://imgur.com/IFaA6Rh

I HAVE not defined VirtualHosts on Tomcat. Based on what I've read, my understanding is that it's only needed if I'm accessing Tomcat directly.

Any assistance is appreciated.

Edit

Here's my worker.properties.

worker.list= LoadBalanceWorker,App1,App2

worker.intApp1.port=8009
worker.intApp1.host=10.15.8.8
worker.intApp1.type=ajp13
worker.intApp1.lbfactor=1
worker.intApp1.socket_timeout=30
worker.intApp1.socket_connect_timeout=5000
worker.intApp1.fail_on_status=302,500,503
worker.intApp1.recover_time=30

worker.intApp2.port=8009
worker.intApp2.host=10.15.8.9
worker.intApp2.type=ajp13
worker.intApp2.lbfactor=1
worker.intApp2.socket_timeout=30
worker.intApp2.socket_connect_timeout=5000
worker.intApp2.fail_on_status=302,500,503
worker.intApp2.recover_time=30

worker.LoadBalanceWorker.type=lb
worker.LoadBalanceWorker.balanced_workers=intApp1,intApp2
worker.LoadBalanceWorker.sticky_session=1
1

Each virtual host in Apache "captures" the request using the ServerName and ServerAlias. The request is then not processed by other virtual hosts. Thus according to your conf:

  • Requests with a hostheader of mysite.com or aliasmysite.ca will gain access only to the URI:s /Webapp1/* and /MonitorApp/*.

  • Similarly, requests with a hostheader of mysite2.com or aliasmysite2.ca will gain access only to the URI /Webapp2/*.

By your description (which is not entirely clear) of your symptoms I interpret these combinations not to work, which therefore would be a completely expected result:

  • mysite2.com/Webapp1/
  • mysite2.com/MonitorApp/
  • mysite.com/Webapp2/

The last one appears to be by intention, the first two not. If this is correct then here is my suggestion:

<VirtualHost 255.255.255.1:80>
    ServerName mysite.com
    ServerAlias aliasmysite.ca
JkMount /Webapp1/* LoadBalanceWorker
JKmount /MonitorApp/* LoadBalanceWorker
</VirtualHost>

<VirtualHost 255.255.255.2:80>
    ServerName mysite2.com
    ServerAlias aliasmysite2.ca
JkMount /Webapp1/* LoadBalanceWorker
JkMount /Webapp2/* LoadBalanceWorker
JKmount /MonitorApp/* LoadBalanceWorker
</VirtualHost>

I hope this is clear enough to lead you on even if I misinterpreted your description.

0

I'm not sure if I understand your architecture right but it looks like you have 2 groups of websites you are trying to separate with domain names. You have only one worker "LoadBalanceWorker". What you should have is two workers one for public apps, the other for employee apps.

  • I will have two groups of workers. I'm still working on setting up the one worker pool. Currently we're running Websphere in two clusters and are trying to migrate to Tomcat. – ttheobald Oct 31 '13 at 18:35
  • I guess my diagram was more complex than it needs to be. I was using it to visualize the problem myself, but I can see that it's confusing. Let's only look at the application server hosting the public applications, mysite.com and mysite2.com – ttheobald Oct 31 '13 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.