【发布时间】:2010-06-30 17:51:43
【问题描述】:
我有一个 Tomcat 6 服务器,我希望几乎所有东西都在 SSL 之后,但是我希望一个 servlet 可以通过非 SSL 访问。可以这样配置Tomcat吗?当前设置为将所有请求转发到安全端口。
【问题讨论】:
我有一个 Tomcat 6 服务器,我希望几乎所有东西都在 SSL 之后,但是我希望一个 servlet 可以通过非 SSL 访问。可以这样配置Tomcat吗?当前设置为将所有请求转发到安全端口。
【问题讨论】:
实现此目的的一种方法是为您的网络应用编辑 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 openforall.jsp 现在可以通过 http 访问了。
注意:如果有人以这种方式访问此 URL,该 URL 也将在 https 上可用。
【讨论】: