Two ways of configuring virtual hosts in Tomcat

1. Virtual host configuration based on host name

Suppose there is hello. Com in the root folder under Tomcat and wenbapps HTML content is written to hello.

Start Tomcat and enter in the browser: http://localhost:8080/index.html ----->It will show that hello accesses the resources under Tomcat

Enter in the browser: http://site1:8080/index.html ------>It will be shown that test accesses the resources under F: \ virtualhost1

In fact, the IP addresses of both are the same, 127.0 0.1, but it realizes the access to resources on two "hosts", one under Tomcat and the other under disk F. If companies a and B are very poor, the website shares a server, but they can't directly enter the IP to enter, because there is only one IP. Here, set a virtual directory on a computer, and the two set different virtual directories. Using the virtual directory name to access can realize public. In fact, it is still an IP and a host.

2. Port based virtual host configuration

Start Tomcat and enter http://localhost:8080/index.html ------->Tomcat / webapps / root / index. Is displayed Content in HTML

Input http://localhost:8082/index.html --------->The index. Under F: \ virtualhost2 is displayed Content in HTML

Here, the configuration of virtual hosts based on different ports is realized through different ports.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>