将http / 8080重定向到https / 8443不适用于Firefox和IE:重定向转到https / 8080

时间:2017-02-13 13:46:45

标签: internet-explorer tomcat firefox ssl redirect

我们希望使用Tomcat 8.5将http / 8080重定向到https / 8443。在Firefox 51.x或IE 11中请求http-URL时,URL被重定向到https://server:8080而不是https://server:8443

这是conf/server.xml

<Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8"
           connectionTimeout="20000"
           redirectPort="8443"
           maxKeepAliveRequests="1" />

<Connector port="8443" protocol="HTTP/1.1" scheme="https" URIEncoding="UTF-8"
           maxThreads="150" SSLEnabled="true">
    <SSLHostConfig>
        <Certificate ... />
    </SSLHostConfig>
</Connector>

这是conf/web.xml

<security-constraint>
    <web-resource-collection>
        <web-resource-name>server</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

以下是运行wget

时的输出
$ wget http://server:8080/ -S
--2017-02-13 14:37:09--  http://server:8080/
Resolving server... <IP>
Connecting to server|<IP>|:8080... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 302
  Cache-Control: private
  Expires: Thu, 01 Jan 1970 01:00:00 CET
  Location: https://server:8443/
  Content-Length: 0
  Date: Mon, 13 Feb 2017 13:37:09 GMT
  Connection: close
Location: https://server:8443/ [following]
--2017-02-13 14:37:09--  https://server:8443/
Connecting to server|<IP>|:8443... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200
  Cache-Control: private
  Expires: Thu, 01 Jan 1970 01:00:00 CET
  Accept-Ranges: bytes
  ETag: W/"1288-1363105010000"
  Last-Modified: Tue, 12 Mar 2013 16:16:50 GMT
  Content-Type: text/html
  Content-Length: 1288
  Date: Mon, 13 Feb 2017 13:37:09 GMT
  Connection: keep-alive
Length: 1288 (1.3K) [text/html]
Saving to: `index.html'

正如您所看到的,响应是重定向(状态302)到预期位置https://server:8443/。由于maxKeepAliveRequests="1",原始请求上的连接已关闭。 wget一切正常。

但是,当将http://server:8080/输入Firefox或IE的地址行时,它会被重定向到https://server:8080/:端口不会更改。

修改:当server更改为服务器的IP(http://IP:8080/)时,Firefox和IE会按照预期重定向到https://IP:8443/

编辑2:清理缓存时,第一个URL重定向按预期工作,而第二个重定向再次失败。这对于Firefox和IE都是如此。 出了什么问题?

0 个答案:

没有答案
相关问题