所以我有一个如下所示的 nginx 配置:
## Redirects all HTTP traffic to the HTTPS host
server {
listen *:80;
server_name me.example.com;
server_tokens off;
return 301 https://me.example.com:443$request_uri;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
server {
listen *:443 ssl;
...
}
server {
listen *:9080;
location / {
root /var/www;
index index.html index.htm;
}
}
Run Code Online (Sandbox Code Playgroud)
目的是将端口 80 上的 http 流量定向到 https (443)。像冠军一样工作。问题是我对端口 9080 的请求导致我的浏览器切换到 https 然后失败(因为我没有在 9080 上使用 ssl,我也不想)。
在 Safari 或 Chrome 中:http://me.example.com:9080/index.html -> https://me.example.com:9080/index.html无法建立安全连接。
使用卷曲:
curl -v http://me.example.com:9080/index.html
* Hostname was NOT found in DNS cache
* Trying x.x.x.x...
* Connected to me.example.com (x.x.x.x) port 9080 (#0)
> GET /index.html HTTP/1.1
> User-Agent: curl/7.37.1
> Host: me.example.com:9080
> Accept: */*
>
< HTTP/1.1 200 OK
* Server nginx/1.4.4 is not blacklisted
< Server: nginx/1.4.4
< Date: Thu, 09 Apr 2015 18:32:02 GMT
< Content-Type: text/html
< Content-Length: 157
< Last-Modified: Thu, 09 Apr 2015 18:19:42 GMT
< Connection: keep-alive
< ETag: "5526c2be-9d"
< Accept-Ranges: bytes
<
<html>
<head>
<title>Test Server</title>
</head>
<body>
<h3>Welcome to the Test Server!"</h3>
</body>
</html>
* Connection #0 to host me.example.com left intact
Run Code Online (Sandbox Code Playgroud)
这是浏览器的问题吗?有什么我可以做的让浏览器开心吗?
更新
在 Chrome 中,您可以通过导航到以下 URL 从 HSTS 中删除站点:
铬://网络内部/#hsts
我猜您正在Strict-Transport-Security从 HTTPS 服务器块发送 HTTP (HSTS) 标头。
HSTS 标头的目的是绑定到它从中接收到的域名。然后它被用户代理 (UA) 称为 HSTS 主机并在其缓存中保留max-age几秒钟。
在此期间,对域或有效子域的进一步 HTTP 请求(如果includeSubDomains指令告知)将通过RFC 6797 第 8.3 节描述的特殊处理:
Run Code Online (Sandbox Code Playgroud)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. NOTE: In the case where an explicit port is provided (and to a lesser extent with subdomains), it is reasonably likely that there is actually an HTTP (i.e., non-secure) server running on the specified port and that an HTTPS request will thus fail (see item 6 in Appendix A ("Design Decision Notes")).
这意味着,如果您尝试向具有匹配域名的已知 HSTS 主机发送 HTTP 请求(详细信息见8.2 节),那么只要 UA 缓存中的 HSTS 主机条目未过期,HTTP 流量就会透明切换到 HTTPS 或者:
| 归档时间: |
|
| 查看次数: |
1480 次 |
| 最近记录: |