简体   繁体   English

为什么 Chrome 浏览器不能识别我的 http2 服务器?

[英]Why doesn't Chrome browser recognize my http2 server?

I setup my Nginx conf as per Digital Ocean paper , and now http2 is available.我按照Digital Ocean 论文设置了我的 Nginx conf,现在 http2 可用。

But in Chrome (Version 54.0.2840.98 (64-bit)) Dev tool, it's always on HTTP 1/1:但是在 Chrome(版本 54.0.2840.98(64 位))开发工具中,它总是在 HTTP 1/1 上:

NAME             METHOD  STATUS  PROTOCOL
shell.js?v=xx..    GET    200     http/1/1

My server is running Ubuntu 16.04 LTS which supports both ALPN & NPN, and the openssl version shipped with it is 1.0.2g.我的服务器运行的是 Ubuntu 16.04 LTS,它支持 ALPN 和 NPN,它附带的 openssl 版本是 1.0.2g。

I checked http2 support with this tool site and the result is:我用这个工具站点检查了 http2 支持,结果是:

Yeah! example.com supports HTTP/2.0. ALPN supported...

Also checking with curl is OK:还检查 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

I also checked with is-http2 cli from my console:我还从控制台检查了 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

Why doesn't Chrome recognise it?为什么 Chrome 无法识别它?

How can I check it also with Safari (v 10.0.1)?我怎样才能用 Safari (v 10.0.1) 检查它?

Will likely be one of two reasons:可能是以下两个原因之一:

  1. You are using anti-virus software and it is MITM your traffic and so downgrading you to HTTP/1.1.您正在使用防病毒软件,并且您的流量是中间人,因此将您降级到 HTTP/1.1。 Turn off https traffic monitoring on your AV to connect directly to the server.关闭 AV 上的 https 流量监控以直接连接到服务器。 You can check if this is the case by using an online tool to test your site for HTTP/2 support .您可以通过使用在线工具测试您的站点是否支持 HTTP/2来检查是否属于这种情况。

  2. You are using older TLS ciphers and specifically one that Chrome disallows for HTTP/2 ( https://http2.github.io/http2-spec/#BadCipherSuites ) as per Step 5 of above guide.根据上述指南的第 5 步,您正在使用旧的 TLS 密码,特别是 Chrome 不允许 HTTP/2 ( https://http2.github.io/http2-spec/#BadCipherSuites ) 使用的密码。 Scan your site using https://www.ssllabs.com/ssltest/ to check your TLS config and improve it.使用https://www.ssllabs.com/ssltest/扫描您的站点以检查您的 TLS 配置并对其进行改进。

The third reason is lack of ALPN support in your SSL/TLS library (ie You are using openssl 1.0.1 and need to be one 1.0.2 or later, for example) but you have already confirmed you have ALPN support so skipping that for this answer.第三个原因是您的 SSL/TLS 库中缺少 ALPN 支持(例如,您使用的是 openssl 1.0.1 并且需要是 1.0.2 或更高版本)但您已经确认您有 ALPN 支持,因此跳过它这个答案。

I had the same issue.我遇到过同样的问题。 I my case it was because I enabled TLS1.3 in NGINX.我的情况是因为我在 NGINX 中启用了 TLS1.3。 See Why is my site not using http/2 while it is http/2 enabled请参阅为什么我的网站在启用了 http/2 时不使用 http/2

In my case, chrome generated following excerpt in chrome-net-export-log.json file.就我而言,chrome 在 chrome-net-export-log.json 文件中生成了以下摘录。

HTTP2_SESSION_RECV_INVALID_HEADER HTTP2_SESSION_RECV_INVALID_HEADER
--> error = "Invalid character in header name." --> error = "标题名称中的字符无效。"
--> header_name = "x-xss-protection:" --> header_name = "x-xss-protection:"
--> header_value = "1; mode=block" --> header_value = "1; mode=block"


After removing : from the header name, the problem was resolved.从标题名称中删除 : 后,问题得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM