In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to achieve multi-domain name access Tomcat, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!
1. First of all, the domain name. Log in to the official website of the World wide Web, fill in the domain name we want to buy, and then query whether it has been preempted. If it has not been preempted, the following is the payment for the purchase.
2, with the domain name, followed by our server, we can choose according to their own needs, such as a small pen, is a poor, then how to simulate this process? The answer is yes, of course. We can use our computer as a server. In this way, there is no need to purchase our domain name. We can customize the local domain name binding by modifying the local hosts file. How to do this: open C:\ Windows\ System32\ drivers\ etc to find the hosts file and open it with notepad. We can see that localhost is bound to our 127.0.0.1.
# localhost name resolution is handled within DNS itself.# 127.0.0.1 localhost#:: 1 localhost
Do you already know what to do when you see here?
3. With the domain name and server, the following is our Tomcat configuration. We know that the Tomcat server listens on port 8080 by default, while the default port of the browser is 80. The following is to modify port 8080 of Tomcat. Open the Tomcat decompression address, find the server.xml under the config folder, and find the
Then change port 8080 to 80 to save, then start Tomcat, enter the domain name we just set in the browser, click enter, and go to the default page of Tomcat, indicating that our configuration is successful.
4. Interspersed with a small configuration description of Tomcat:
We all know that there is a character length limit for get requests, so is there a length limit for post requests? It is believed that children's shoes who have written the APP service interface can encounter such a scenario. When the app side uploads photos through Base64, when the photo size exceeds 2m, our server will not receive the data packet. What is the problem? Of course, the answer is not that post has a limit on the length of packets, because there is a default length limit on the length of packets in Tomcat, and the maximum supported length is 2m. This can also be solved by adding: maxPostSize= "- 1" under server.xml.
5. The following is the binding of our domain name to the project:
Or the above server.xml file, we look for the Engine tag, and then we can see:
This is our Tomcat default binding, and we can access the project directly through localhost. This is the configuration. Let's configure a configuration that accesses the project through the domain name. Under the Engine tag, we are adding a Host configuration:
Note: the Context tag must be placed under Value, otherwise Tomcat startup will report an error. Here two parameters are explained: the actual path of the docBase project and the virtual path of the path project access. Simply put, docBase points to the specific location of our project, and path provides us with the access path.
6. How to bind multiple domain names
As simple as above, we can add a few more Host configurations under the Engine tag.
7. Finally, I need to say a few points:
DefaultHost refers to the default Host configuration. When the access domain name is not bound, the default Host configuration is used.
The default localhost configuration under the Engine tag is to access the domain name + project name for the domain name that is not bound to the project.
The above is all the contents of the article "how to achieve multi-domain name access in Tomcat". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.