Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to host multiple sites at Tomcat?

Tags:

tomcat

Is it possible to host multiple sites with Tomcat? Each site has to have its own domain name and "/" context. I failed to find any documentation/instructions about this.

like image 543
yegor256 Avatar asked Jan 20 '23 07:01

yegor256


1 Answers

Definitely possible, and very easy. The Tomcat master configuration file conf/server.xml can contain multiple elements, each of which contains their own settings and webapp definitions. Tomcat will match incoming requests against these hosts (host aliases are also supported) and forward the request to the correct webapp.

So, typically you would add a declaration with a host-specific app-base directory, then drop a WAR into that directory and it would work.

See The Host Container for specific host configuration.

like image 60
Shay Rojansky Avatar answered Jan 29 '23 13:01

Shay Rojansky