http请求+端口8443

时间:2014-01-17 00:45:19

标签: java eclipse tomcat https

我的问题非常相似(accessing port 8443 with http in tomcat),但问题没有得到解答。

我正在开发一个网站,我正在使用Eclipse Juno和Tomcat 7。 我已将tomcat配置为接受https请求。

<Connector SSLEnabled="true" 
           clientAuth="false" 
           keystoreFile="C:\ssl\.keystore" 
           keystorePass="changeit" 
           maxThreads="150" 
           port="8443" 
           protocol="HTTP/1.1" 
           scheme="https" 
           secure="true" 
           sslProtocol="TLS"/>

因此,当您通过https + 8443访问该站点时,它会显示一条警告消息,因此已成功配置。

此外,我将所有http请求重定向到https,方法是将此代码添加到我的web.xml:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>HTTPSOnly</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>HTTPSOrHTTP</web-resource-name>
        <url-pattern>*.ico</url-pattern>
        <url-pattern>/img/*</url-pattern>
        <url-pattern>/css/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>

因此,当您使用http + 8080访问该网站时,您将被重定向到https + 8443。

然而,我遇到的一个问题是当用户使用http + 8443时。 因此,当您访问URL时,它会提示下载对话框。

使用http + 8443访问网站时,有没有办法抛出错误信息或重定向?

0 个答案:

没有答案
相关问题