Tomcat Virtual Host Configuration

Source: Internet
Author: User

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 &quot;%r&quot;%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 &quot;%r&quot;%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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.