How to configure the global error page in Tomcat + delete the built-in items under the webapps directory in Tomcat to prevent Tomcat default files from leaking
Editor to share with you how to configure the global error page in Tomcat + delete the built-in items in the webapps directory in Tomcat to prevent Tomcat default files from leaking. I hope you will get something after reading this article. Let's discuss it together.
Go to the conf file in the tomcat directory to edit web.xml, and copy the following code to the end of the file, as follows
400 / error.html 404/404 / 404.html 500 / 404/500.html
two。 Add 404,400500 pages to your project, and also put a 404 page in the global webapp directory.
3. Start Tomcat and deliberately visit a page that does not exist. The success is as follows:
Gitee address: https://gitee.com/zhugekongan/depository404.git
3. Delete the built-in projects in the webapps directory in Tomcat (tomcat7 is the same as tomcat8). For some developers, these projects have an impact on the performance, security or other aspects of Tomcat, so you need to delete these self-contained projects. The folders docs, examples and ROOT can be deleted directly. After deleting the host-manager and manager folders, you need to modify part of the file configuration, otherwise an exception will be thrown when the log is output, such as "host-manager not found" and so on.
1. Configure the tomcat/conf/logging.properties file before deletion
# Delete all items beginning with 3manager and 4host-manager: # Delete: 3manager.org.apache.juli.AsyncFileHandler, # Delete: 4hosttel manager.org.apache.juli.AsyncFileHandlerhandlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler In java.util.logging.ConsoleHandler# Handler specific properties, you need to delete the section 3manager.org.apache.juli.AsyncFileHandler.level = FINE3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base} / logs3manager.org.apache.juli.AsyncFileHandler.prefix = manager.4host-manager.org.apache.juli.AsyncFileHandler.level = FINE4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base} / logs4host-manager.org.apache.juli.AsyncFileHandler.prefix = Host-manager.# Facility specific properties You need to delete the part org.apache.catalina.core.ContainerBase.[ manager]. Level = INFOorg.apache.catalina.co.ContainerBase.[ Catalina] .[ / manager] .handlers = 3manager.org.apache.j uli.AsyncFileHandlerorg.apache.catalina.co.ContainerBase.[ Catalina] .[ localhost]. [/ host-manager]. Level = INFOorg.ache.catalina.core.Container.Container.Base.[ localhost]. [localhost]. Handlers = 4host-manager.org.apache.juli.AsyncFileHandler
two。 It's done. Delete everything except your own project. If you delete it, you'll find it much easier. If you visit IP directly, you won't have a tomcat page.
After reading this article, I believe you have a certain understanding of "how to configure the global error page in Tomcat + delete the built-in items under the webapps directory in Tomcat to prevent the leakage of Tomcat default files". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!