gpt4 book ai didi

tomcat - 在 Tomcat 6 中同时使用 SSL 和非 SSL

转载 作者:行者123 更新时间:2023-11-28 21:48:01 25 4
gpt4 key购买 nike

我有一台 Tomcat 6 服务器,我希望几乎所有内容都支持 SSL,但我希望可以通过非 SSL 访问一个 servlet。可以这样配置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 添加另一个 block 。

    <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>

现在可以通过 http 单独访问此 URL openforall.jsp。

注意:如果有人以这种方式访问​​该 URL,该 URL 也将在 https 上仍然可用。

关于tomcat - 在 Tomcat 6 中同时使用 SSL 和非 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3151955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com