2011-06-03 70 views
1

我想使我的Tomcat7服務器的默認頁面是私人的,即只有在輸入密碼.htaccess後方可使用。如何保護Tomcat的默認頁面?

我的意思是這個頁面:

Tomcat default page

爲此,我說:

<user username="admin" password="admin" roles="manager-gui"/> 

tomcat-users.xml

然後我說:

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>Entire Application</web-resource-name> 
     <url-pattern>/references/*</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
     <role-name>admin</role-name> 
    </auth-constraint> 
</security-constraint> 

<!-- Define the Login Configuration for this Application --> 
<login-config> 
    <auth-method>BASIC</auth-method> 
    <realm-name>Application</realm-name> 
</login-config> 

<!-- Security roles referenced by this web application --> 
<security-role> 
    <description> 
    The role that is required to log in to the Manager Application 
    </description> 
    <role-name>admin</role-name> 
</security-role> 

webapps/ROOT/WEB-INF/web.xml

但是,當我打開默認頁面,htaccess對話框仍然不會出現。

我在做什麼錯?

+0

請參見:[指定認證機制](http://docs.oracle.com/cd/E19226-01/820-7627/bncbn/index.html) – kenorb 2015-04-10 12:46:32

回答

2

看看你<url-pattern>,它指向/references/*(不根文件夾存在) 典型的Tomcat設置的歡迎頁面是在根文件夾,因此<url-pattern>應指向/*

+0

感謝您的回答! – 2011-06-03 17:00:08