仅在localhost上禁用https

时间:2017-08-23 05:00:27

标签: java tomcat jboss tomcat7

我正在使用tomcat 7,我想仅从localhost禁用SSL流量来源!并为入站流量启用它。

我已将以下配置添加到web.xml,并且它目前将流量从http重定向到https。

<security-constraint>
    <web-resource-collection>
        <web-resource-name>app</web-resource-name>
        <url-pattern>/info</url-pattern>
    </web-resource-collection>
    <!-- OMIT auth-constraint -->
</security-constraint>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>app</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>Role</role-name>
    </auth-constraint>
</security-constraint>

我的服务器上有一个自定义备份工具,无法使用HTTP,因此我希望在localhost上禁用HTPP。

2 个答案:

答案 0 :(得分:2)

您可以在server.xml文件的下面注释。

<Connector port="8443" ... SSLEnabled="true" scheme="https" secure="true" sslProtocol="TLS" ... />

希望这会有所帮助!!

答案 1 :(得分:0)

您可以禁用特定的 url,只需将 NONE 放在传输保证标签上,检查 Is security-constraint configuration for Tomcat mandatory?

<security-constraint>
    <web-resource-collection>
        <web-resource-name>securedapp</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>securedapp</web-resource-name>
        <url-pattern>/info/*</url-pattern>
        <url-pattern>/info2/*</url-pattern>
        <url-pattern>/info3/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>