为什么 Chrome 浏览器不能识别我的 http2 服务器?
Why doesn't Chrome browser recognize my http2 server?
我按照 Digital Ocean paper 设置我的 Nginx conf,
现在 http2 可用了。
但在 Chrome(版本 54.0.2840.98(64 位))开发工具中,它始终在 HTTP 1/1 上:
NAME METHOD STATUS PROTOCOL
shell.js?v=xx.. GET 200 http/1/1
我的服务器是运行 Ubuntu 16.04 LTS同时支持ALPN & NPN,自带的openssl版本是1.0.2g。
我用 this tool site 检查了 http2 支持,结果是:
Yeah! example.com supports HTTP/2.0. ALPN supported...
也用curl检查也可以:
$ curl -I --http2 https://www.example.com
HTTP/2 200
server: nginx/1.10.0 (Ubuntu)
date: Tue, 13 Dec 2016 15:59:13 GMT
content-type: text/html; charset=utf-8
content-length: 5603
x-powered-by: Express
cache-control: public, max-age=0
etag: W/"15e3-EUyjnNnyevoQO+tRlVVZxg"
vary: Accept-Encoding
strict-transport-security: max-age=63072000; includeSubdomains
x-frame-options: DENY
x-content-type-options: nosniff
我还从我的控制台检查了 is-http2 cli:
is-http2 www.amazon.com
× HTTP/2 not supported by www.amazon.com
Supported protocols: http/1.1
is-http2 www.example.com
✓ HTTP/2 supported by www.example.com
Supported protocols: h2 http/1.1
为什么Chrome不认识?
我怎样才能用 Safari (v 10.0.1) 也检查它?
可能是以下两个原因之一:
您正在使用防病毒软件,您的流量是 MITM,因此将您降级到 HTTP/1.1。关闭AV上的https流量监控,直接连接服务器。您可以使用 an online tool to test your site for HTTP/2 support.
检查是否属于这种情况
您正在使用较旧的 TLS 密码,特别是 Chrome 不允许 HTTP/2 的密码(https://http2.github.io/http2-spec/#BadCipherSuites) as per Step 5 of above guide. Scan your site using https://www.ssllabs.com/ssltest/ 检查您的 TLS 配置并改进它。
第三个原因是lack of ALPN support in your SSL/TLS library(例如,您使用的是 openssl 1.0.1 并且需要是 1.0.2 或更高版本)但是您已经确认您有 ALPN 支持所以跳过它这个答案。
我遇到了同样的问题。我的情况是因为我在 NGINX 中启用了 TLS1.3。参见
就我而言,chrome 在 chrome-net-export-log.json 文件中生成了以下摘录。
HTTP2_SESSION_RECV_INVALID_HEADER
--> error = "header 名称中的无效字符。"
--> header_name = "x-xss-protection:"
--> header_value = "1;mode=block"
从 header 名称中删除 : 后,问题得到解决。
我按照 Digital Ocean paper 设置我的 Nginx conf, 现在 http2 可用了。
但在 Chrome(版本 54.0.2840.98(64 位))开发工具中,它始终在 HTTP 1/1 上:
NAME METHOD STATUS PROTOCOL
shell.js?v=xx.. GET 200 http/1/1
我的服务器是运行 Ubuntu 16.04 LTS同时支持ALPN & NPN,自带的openssl版本是1.0.2g。
我用 this tool site 检查了 http2 支持,结果是:
Yeah! example.com supports HTTP/2.0. ALPN supported...
也用curl检查也可以:
$ curl -I --http2 https://www.example.com
HTTP/2 200
server: nginx/1.10.0 (Ubuntu)
date: Tue, 13 Dec 2016 15:59:13 GMT
content-type: text/html; charset=utf-8
content-length: 5603
x-powered-by: Express
cache-control: public, max-age=0
etag: W/"15e3-EUyjnNnyevoQO+tRlVVZxg"
vary: Accept-Encoding
strict-transport-security: max-age=63072000; includeSubdomains
x-frame-options: DENY
x-content-type-options: nosniff
我还从我的控制台检查了 is-http2 cli:
is-http2 www.amazon.com
× HTTP/2 not supported by www.amazon.com
Supported protocols: http/1.1
is-http2 www.example.com
✓ HTTP/2 supported by www.example.com
Supported protocols: h2 http/1.1
为什么Chrome不认识?
我怎样才能用 Safari (v 10.0.1) 也检查它?
可能是以下两个原因之一:
您正在使用防病毒软件,您的流量是 MITM,因此将您降级到 HTTP/1.1。关闭AV上的https流量监控,直接连接服务器。您可以使用 an online tool to test your site for HTTP/2 support.
检查是否属于这种情况
您正在使用较旧的 TLS 密码,特别是 Chrome 不允许 HTTP/2 的密码(https://http2.github.io/http2-spec/#BadCipherSuites) as per Step 5 of above guide. Scan your site using https://www.ssllabs.com/ssltest/ 检查您的 TLS 配置并改进它。
第三个原因是lack of ALPN support in your SSL/TLS library(例如,您使用的是 openssl 1.0.1 并且需要是 1.0.2 或更高版本)但是您已经确认您有 ALPN 支持所以跳过它这个答案。
我遇到了同样的问题。我的情况是因为我在 NGINX 中启用了 TLS1.3。参见
就我而言,chrome 在 chrome-net-export-log.json 文件中生成了以下摘录。
HTTP2_SESSION_RECV_INVALID_HEADER
--> error = "header 名称中的无效字符。"
--> header_name = "x-xss-protection:"
--> header_value = "1;mode=block"
从 header 名称中删除 : 后,问题得到解决。