probe现官方仓库为https://github.com/psi-probe
本文的Tomcat版本为8.5.30,probe版本为3.2.0 Release
- 在conf/tomcat-users.xml添加如下内容,配置tomcat管理角色,打开manager应用
<role rolename="probeuser" /> <role rolename="poweruser" /> <role rolename="poweruserplus" /> <role rolename="manager-gui"/> <user username="asyouwish" password="asyouwish" roles="manager-gui"/>
- 修改manager/META-INF/context.xml,放开访问源限制,默认配置只允许127开头的本地地址进行访问
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
此时重启tomcat,会部署webapps下manager文件夹中的应用,访问host/manager可以访问管理页面
- 下载probe.war放入webapps下,重启服务器。
因为我使用的服务器之前配置了只允许https访问,此时访问host/probe会提示no sufficient privilege to access,然后在问答区找到了解决方案,不过奇怪的是官方回答tomcat8.5版本不需要额外配置,而我是在配置后解决问题的。
(有误,只需在项目的web.xml中配置即可)修改conf/web.xml,添加一个<security-constraint>,并在其中设置auth-constraint,要注意url(/probe/*)匹配不能与其他<security-constraint>重复,据说若多个<security-constraint>匹配到相同的url,则访问该url时tomcat会选择不需要权限(role-name)的。<login-config> <!-- Authorization setting for SSL --> <auth-method>CLIENT-CERT</auth-method> <realm-name>Client Cert Users-only Area</realm-name> </login-config> <security-constraint> <web-resource-collection > <web-resource-name >probe</web-resource-name> <url-pattern>/probe/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>probeuser</role-name> <role-name>poweruser</role-name> <role-name>manager-gui</role-name> <role-name>poweruserplus</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> <security-constraint> <web-resource-collection > <web-resource-name >SSL</web-resource-name> <url-pattern>/myweb/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>