tomcat configuration domain name

Now many companies' websites use tomcat as the application service area, but for beginners, how to remove the 8080 port number, and how are these websites bound to the domain name? How does a tomcat bind multiple domain names? And how do these domain names correspond to different projects? And my server is not placed in the computer room, but in my local area. How should I map my server to the external network? I will talk about this series of questions today.

1.  Domain name . Now the domain name is not very expensive, many people have it, and the website where we register the domain name will also have a DNS to help resolve, which is to bind the IP of the server to these domain names .

2. We have a domain name , now let's talk about our projects; for example, I have two projects under my tomcat . Then we can access our abc project by entering http://localhost:8080/abc, but how to remove the port number 8080 ?

There is a server.xml under tomcat 's conf folder. We open this file and find 8080, just change 8080 to 80. When we enter http://localhost/abc again.

3. But how does our domain name bind to the project ? We again find server.xml in the conf folder under tomcat.

Modify <Host name="The domain name we want to bind " debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"></Host>

4. When starting tomcat , enter the domain name we bind to , whether you can see our tomcat . However, if we want to access our project, we have to add the project name to the domain name before we can access it , which means that our domain name has not yet been bound to the project .

We are looking at the third part and want to bind our project and domain name together , we just need to add <Context docBase="project name" path="" reloadable="true" > before </Host> that is Can.

例如:<Host name="www.abc.com" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"><Context docBase="baidu" path=""  reloadable="true" ></Host>

5. When we have two projects under the same tomcat , we only need to add two <Host></Host> to complete the binding of our two projects, but the project name is different. Forgot to change it.

6. When our server is maintained by itself (not placed in the computer room), we need to map our routes. Take my route as an example. My router is a TP-LINK WR340G model. After entering the router, we can find a forwarding rule. There is a virtual server in it. After clicking the new entry, there will be: service port number, IP address, protocol, status , Common service port number. We only need the IP address here (the server's LAN IP), select ALL for the protocol (some routes don't seem to have this option, so you don't need to fill in it), select the status to take effect, and select HTTP or WEB for the common service port number. In this case, the default port number is 80. When the common service port number does not have HTTP or WEB, you can choose DNS, and then manually change the port number to 80. Click to take effect. Just save it. If the route mapping I mentioned is not applicable to you or you do not understand it, you can find various route mapping methods on the Internet.

7. At this time, we are entering our domain name , so we can directly access our project.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327033403&siteId=291194637