Tomcat multi-domain configuration and Tomcat Domain Configuration
Environment
One tomcat, multiple projects are deployed below
There is an independent IP Address
Multiple top-level (second-level) domain names direct to different projects.
DNS Configuration
DNS has no special requirements. You only need to point all configurations to this IP address.
Tomcat configuration
There may be multiple configuration methods for multiple domain names. I use a method (file structure) that looks troublesome.
Connector
The configuration methods are basically the same:
<Connector port="80" protocol="HTTP/1.1" URIEncoding="UTF-8" connectionTimeout="20000" redirectPort="8443" />
First, all ports are 80. GenerallyURIEncoding="UTF-8"
Prevent garbled characters.
The following describes how to configure multiple domain names:
<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 atdefaultHost="www.mybatis.tk"
This configuration means that the domain name host (Host
Ofname
).
The following top-level (and second-level) domain name configurations are the same:
<Host name="www.mybatis.tk" appBase="webapps" unpackWARs="true" autoDeploy="true"></Host>
Note thatappBase
In the tomcat directory.webapps
Directory. By defaultROOT
. So this configuration is actually equivalentwebapps/ROOT
.
The other items in the complete configuration abovedocapps,mbg,spring
It is also directly in the tomcat directory (andwebapps
Is a level directory), all haveROOT
Directory, the deployed projects are also directly inROOT
.
After the above configuration, you can access it normally.
The website configured above is the following website Region
Welcome to MyBatis tool: www. mybatis. tk Chinese document directory: www. cndocs. tkSpring4 Chinese document: spring. cndocs. tkMyBatis Generator Chinese document: mbg. cndocs. tk