user1143343
user1143343

Reputation: 255

Using multiple tomcat instances with 80 port

I have three tomcat instances for three different applications. They are using 8080,8081,8082 ports in one machine. How can I change configurations so that users are able to access from 80 port with different host names? I have installed an Apache on my machine and tried to configure it with following tutorial: How to load balance Tomcat 5.5 with Apache on Windows until load balancing point starts. I have questions based on this tutorial. My web applications is under webapps/ROOT in all tomcat instances. I have this configuration in httpd.conf:

<IfModule jk_module>
    JkWorkersFile  D:\containters\_tomcat_backend\conf\workers.properties
    JkShmFile      D:\containters\_tomcat_backend\logs\mod_jk.shm
    JkLogFile      D:\containters\_tomcat_backend\logs\mod_jk.log
    JkLogLevel debug
    JkMount / worker1
    JkMount / worker2
</IfModule>

And I'm getting this warining when I run httpd.exe from command prompt:

[warn] NameVirtualHost *:80 has no VirtualHosts

Am I in correct way to make my applications work with 80 port? And how can I configure this warning?

Upvotes: 3

Views: 2000

Answers (1)

f_puras
f_puras

Reputation: 2504

For your scenario, you will not need load balancing. In your httpd.conf, you should define 3 virtual hosts for the host names you want to use (as described here). In each of the VirtualHost directives, insert a JkMount for a worker to be defined in your workers.properties like:

JkMount /* worker1
...

# same for worker2 and worker3 in the other virt. hosts

Now comes the workers.properties:

...
worker.list = worker1, worker2, worker3

worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13

worker.worker2.port=8010
worker.worker2.host=localhost
worker.worker3.type=ajp13

worker.worker3.port=8011
worker.worker3.host=localhost
worker.worker3.type=ajp13

N.B.: I use different ports than the ones you specified, because communication between Apache and Tomcat is runs via AJP. Finally, add a matching AJP connector in each of your tomcat's server.xml:

<Connector port="8009" protocol="AJP/1.3" />

See this for more details. The warning you mentioned seems to be caused by an incomplete virtual host configuration. Are there no VirtualHost instances defined yet?

Edit: If you don't like that much configuration, you could also use your Apache as a proxy and distribute traffic to your tomcats via the ProxyPass/ProxyPassReverse directives.

Upvotes: 2

Related Questions