2010-06-30 44 views
5

我有一個Tomcat 6服務器,我希望所有東西都在SSL後面,但是我希望通過非ssl訪問一個servlet。這樣可以配置Tomcat嗎?它目前設置爲將所有請求轉發到安全端口。在Tomcat 6中同時使用SSL和非SSL

回答

5

實現此目的的一種方法是編輯web應用程序的web.xml。

我假設你已經有Web應用程序設置爲強制與<transport-guarantee> CONFIDENTIAL所有請求到https像下面

<security-constraint> 
     <display-name>Example Security Constraint</display-name> 
     <web-resource-collection> 
     <web-resource-name>Protected Area</web-resource-name> 
    <!-- Define the context-relative URL(s) to be protected --> 
     <url-pattern>/*</url-pattern> 
    <!-- If you list http methods, only those methods are protected --> 
    <http-method>DELETE</http-method> 
     <http-method>GET</http-method> 
     <http-method>POST</http-method> 
    <http-method>PUT</http-method> 
     </web-resource-collection> 
     <auth-constraint> 
     <!-- Anyone with one of the listed roles may access this area --> 
     <role-name>tomcat</role-name> 
    <role-name>role1</role-name> 
     </auth-constraint> 
     <user-data-constraint> 
<transport-guarantee>CONFIDENTIAL</transport-guarantee> 
</user-data-constraint> 
    </security-constraint> 

現在低於此添加其他塊要繞過HTTPS爲servlet。

<security-constraint> 
<web-resource-collection> 
<web-resource-name>Unsecured resources</web-resource-name> 
<url-pattern>/jsp/openforall.jsp</url-pattern> 
</web-resource-collection> 
<user-data-constraint> 
<transport-guarantee>NONE</transport-guarantee> 
</user-data-constraint> 
</security-constraint> 

這個URL現在可以通過http訪問openforall.jsp。

注意:如果有人以這種方式訪問​​,此URL也將在https上可用。