1. Virtual Hosting
When the server receives a client request, it responds by selecting a Web site based on the host header in the HTTP request message. When a request is sent, the host name in the URL is sent to the server as host in the HTTP request message. Therefore, the virtual host can be set according to different host to reach the different Web sites under the IP and port.
The request message format that the browser sends to the server is as follows:
GET / http/1.1 Host: www.baidu.com
Settings for 2.tomcat Virtual hosts
Implementation of the virtual host by setting the host node in Server.xml to implement host name access by setting the system host file (SYSTEM32/DRIVERS/ETC)
1 <HostAppBase= "WebApps"Autodeploy= "true"name= "localhost"Unpackwars= "true">2 3 <ValveClassName= "Org.apache.catalina.valves.AccessLogValve"Directory= "Logs"pattern= "%h%l%u%t "%r"%s%b"prefix= "Localhost_access_log."suffix= ". txt"/>4 5 <ContextDocBase= "MyWeb"Path= "/myweb"reloadable= "true"Source= "Org.eclipse.jst.jee.server:myweb"/>6 7 <ContextDocBase= "MobileWeb"Path= "/mobileweb"reloadable= "true"Source= "Org.eclipse.jst.jee.server:mobileWeb"/>8 9 </Host>Ten One<HostAppBase= "WebApps"Autodeploy= "true"name= "MyWeb"Unpackwars= "true"> A - <ValveClassName= "Org.apache.catalina.valves.AccessLogValve"Directory= "Logs"pattern= "%h%l%u%t "%r"%s%b"prefix= "Localhost_access_log."suffix= ". txt"/> - the <ContextDocBase= "MyWeb"Path= "/myweb"reloadable= "true"Source= "Org.eclipse.jst.jee.server:myweb"/> -</Host>
Translated from: http://blog.csdn.net/xiaojianpitt/article/details/2153936
http://blog.csdn.net/aoxida/article/details/7045985
Tomcat Virtual Host Configuration