主端口 80 上的 hsts,而不是其他端口

Len*_*nne 10 hsts

我在网站http://server.mydom.tld:80上为我的域设置了 hsts ,因此浏览器转到端口 443 上的端口https://server.mydom.tld

但是,我还有其他网络服务器,在其他端口上运行。因此,当我访问http://server.mydom.tld:8888 时,它会被转发到https://server.mydom.tld:8888,但该服务器不运行 https,因此请求失败。

那是根据规范吗?

我注意到我没有在http://mydom.tldhttp://www.mydom.tld上运行 hsts ,这可能是一个错误。

该怎么办?

小智 16

是的,这是故意的。RFC 6797规定:

     The UA MUST replace the URI scheme with "https" [RFC2818], and

     if the URI contains an explicit port component of "80", then
     the UA MUST convert the port component to be "443", or>>

     if the URI contains an explicit port component that is not
     equal to "80", the port component value MUST be preserved;
     otherwise,

     if the URI does not contain an explicit port component, the UA
     MUST NOT add one.

     NOTE:  These steps ensure that the HSTS Policy applies to HTTP
            over any TCP port of an HSTS Host.
Run Code Online (Sandbox Code Playgroud)

您应该在不同的域上运行纯 HTTP 服务,或者更好的是,使用 HTTP+TLS 服务器作为内部纯 HTTP 服务的反向代理。