简体   繁体   中英

How to prevent undeploying applications in Tomcat Apache 7

I am getting one problem 在此处输入图片说明

I want to hide undeploy option

Is it possible ? If so please help me out.

Thanks in Advance,

You will have to set different roles for the deploy and undeploy operations.

First, register the roles in $TOMCAT_DIR/conf/tomcat-users.xml . For example:

<role rolename="deploy"/>
<role rolename="undeploy"/>

Then, open the $TOMCAT_DIR/webapps/manager/WEB-INF/web.xml and ensure the following:

<security-constraint>
  <web-resource-collection>
    <web-resource-name>Manual Deployment</web-resource-name>
    <url-pattern>/html/deploy</url-pattern>
  </web-resource-collection>
  <auth-constraint>
     <role-name>manager-gui</role-name>
     <role-name>deploy</role-name>
  </auth-constraint>
</security-constraint>

<security-constraint>
  <web-resource-collection>
    <web-resource-name>Manual Deployment</web-resource-name>
    <url-pattern>/html/undeploy</url-pattern>
  </web-resource-collection>
  <auth-constraint>
    <role-name>manager-gui</role-name>
    <role-name>undeploy</role-name>
  </auth-constraint>
</security-constraint>

This will allow only the users which have a undeploy role to undeploy applications and only the users who have deploy role to deploy applications. Note that an user can be decorated with more than on role.

Finally, decorate your user with some of the newly created roles, restart Tomcat and see what happens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM