加固前请对系统业务运行的服务、端口等信息进行摸查及评估,并在测试机先行测试,加固不规范,老板扔炸弹。
8版本以前已经停止更新,不建议使用
Tomcat下载地址: https://archive.apache.org/dist/tomcat/
将部署 Tomcat
目录下 webapps
下与业务代码无关的文件夹全部删除
如果前面管理界面关了,那这个当我没说。
如果非开这个管理页面不可,那就把默认账户修改掉咯,修改掉/Tomcat目录/conf
中tomcat-users.xml
默认用户,例如把Tomcat
用户改成nginx
,再设置一个自己都记不住的密码🙂。
使用普通用户启动
进入 /tomcat
目录/lib
找到catalina.jar
解压:jar xf catalina.jar
进入org/apache/catalina/util
编辑ServerInfo.properties
删除后重新将文件打包成jar
jar uvf catalina.jar org/apache/catalina/util/ServerInfo.properties
重启tomcat
检验:
curl IP:port | grep "Apache Tomcat"
这里说一个恐怖的事情,加固到后面有可能不知道用了什么版本。
删除webapps目录下的示例:
docs、examples、host-manager、manager、ROOT
安装目录下,conf
文件夹中,web.xml
,将listings
改成false
编辑/tomcat
目录/conf/context.xml
,新增<Context useHttpOnly="true">
编辑/tomcat
目录/conf/server.xml
,将默认8005端口改为“-1”或更改shutdown
命令,防止被恶意远程重启。
编辑/tomcat
目录/conf/server.xml
,将AJP
端口改为-1
编辑server.xml
中的host
项中,修改autoDeploy="false"
如果前置nginx
的话,在nginx
做也行,看你喜欢,做之前要看应用系统是否有用到这些http
方法。
conf
文件夹中,web.xml
xml<security-constraint>
<web-resource-collection>
<web-resource-name>fortune</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint></auth-constraint>
</security-constraint>
tomcat目录下的conf目录,找到server.xml文件。
xml<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
本文作者:XiaoWang0777
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!