feat: 增加Tomcat测试环境

This commit is contained in:
ZacharyZcR 2024-12-23 03:42:46 +08:00
parent 1f860f22c8
commit 57b6d41737
4 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,17 @@
FROM tomcat:9.0-jdk8
# 删除默认应用
RUN rm -rf /usr/local/tomcat/webapps/*
# 复制tomcat-users.xml配置文件
COPY tomcat-users.xml /usr/local/tomcat/conf/
# 允许远程访问manager
COPY context.xml /usr/local/tomcat/webapps.dist/manager/META-INF/
COPY context.xml /usr/local/tomcat/webapps.dist/host-manager/META-INF/
# 复制默认应用
RUN cp -r /usr/local/tomcat/webapps.dist/* /usr/local/tomcat/webapps/
EXPOSE 8080
CMD ["catalina.sh", "run"]

View File

@ -0,0 +1,2 @@
docker build -t tomcat-weak .
docker run -d --name tomcat-test -p 8080:8080 tomcat-weak

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="false" privileged="true" >
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow=".*" />
</Context>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="admin" password="123456" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
<user username="both" password="both" roles="manager-gui,admin-gui"/>
<user username="root" password="root123" roles="manager-gui,manager-script"/>
</tomcat-users>