Environment
One tomcat, with multiple projects deployed below
There is an independent IP
There are multiple top level (level two) domain names that point to different projects.
DNS Configuration
DNS has no special requirements, the configuration points to this IP on the line.
Tomcat Configuration
Multiple domain names can be configured in many ways, and I use one (file structure) to look at the more troublesome way.
ConnectorAre configured basically the same way:
<Connector port="80" protocol="HTTP/1.1" URIEncoding="UTF-8" connectionTimeout="20000" redirectPort="8443" />
The first port is 80, generally will also take on to URIEncoding="UTF-8" prevent garbled.
Here's how to configure multiple domains:
<Engine name="Catalina" defaulthost="www.mybatis.tk"> <Host name="www.mybatis.tk"appBase="WebApps"unpackwars ="true" autodeploy="true"> </Host> <Host name="www.cndocs.tk"appBase="Docapps" Unpackwars="true" autodeploy="true"> </Host> <Host name="mbg.cndocs.tk"appBase="MBG"unpackwars= "true" Autodeploy="true"> </Host> <Host name="spring.cndocs.tk"appBase="Spring"unpackwars ="true" autodeploy="true"> </Host></Engine>
First look at the first line defaultHost="www.mybatis.tk" , this configuration means that when accessed through the IP address, the use of the domain host (and the following specific Host name consistency).
The following top level (and level two) domain name configurations are the same:
<Host name="www.mybatis.tk" appBase="webapps" unpackWARs="true" autoDeploy="true"></Host>
It is important to note here that the appBase directory under the Tomcat directory is pointed to, by default, to the directory webapps ROOT . So this configuration is actually equivalent webapps/ROOT .
The rest of the above full configuration docapps,mbg,spring is also directly under Tomcat directory (and webapps is a peer directory), there are ROOT directories, deployed projects are also directly ROOT under.
As configured above, it is normal to have access.
The sites configured above are the following URLs ↓
Welcome to MyBatis Tool: www.mybatis.tk Chinese document directory: Www.cndocs.tkSpring4 Chinese document: Spring.cndocs.tkMyBatis generator Chinese Document: mbg.cndocs.tk
Tomcat Multi-domain Configuration