为什么 Chrome 浏览器无法识别我的 nginx http2 服务器?

erw*_*win 6 nginx google-chrome http2

我按照Digital Ocean 论文设置了我的 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
Run Code Online (Sandbox Code Playgroud)

我的服务器运行的是支持 ALPN 和 NPN 的 Ubuntu 16.04 LTS,它附带的 openssl 版本是 1.0.2g

我使用此工具站点检查了 http2 支持,结果是:

Yeah! example.com supports HTTP/2.0. ALPN supported...
Run Code Online (Sandbox Code Playgroud)

也检查 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
Run Code Online (Sandbox Code Playgroud)

我还从控制台检查了 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
Run Code Online (Sandbox Code Playgroud)

从我的本地主机用 openssl 测试

$ echo | openssl s_client -alpn h2 -connect www.example.com:443 | grep ALPN
 depth=2 O = Digital Signature Trust Co., CN = DST Root CA X3
 verify return:1
 depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
 verify return:1
 depth=0 CN = example.com
 verify return:1
 ALPN protocol: h2
 DONE
Run Code Online (Sandbox Code Playgroud)

为什么 Chrome 被抛在了后面呢?我怎样才能用 Safari (v 10.0.1) 检查它

Bar*_*ard 17

根据我在StackOverflow 上的回答:

可能是以下两个原因之一:

  1. 您正在使用防病毒软件,并且您的流量是中间人,因此将您降级到 HTTP/1.1。关闭 AV 上的 https 流量监控以直接连接到服务器。

  2. 根据上述指南的第 5 步,您正在使用旧的 TLS 密码,特别是 Chrome 不允许 HTTP/2 ( https://http2.github.io/http2-spec/#BadCipherSuites )使用的密码。使用https://www.ssllabs.com/ssltest/扫描您的站点以检查您的 TLS 配置并对其进行改进。

第三个原因是您的 SSL/TLS 库中缺少 ALPN 支持(例如,您使用的是 openssl 1.0.1 并且需要是 1.0.2 或更高版本)但您已经确认您有 ALPN 支持,因此跳过它这个答案。