Chrome 在 spnego 需要 401 后强制使用 http1.1 而不是 h2

Chrome forces http1.1 instead of h2 after 401 needed for spnego

我将 nginx + spnego 模块配置为通过特定地址的 sso 登录用户,并注意到一旦发生这种情况,chrome 就会对整个子域强制 http/1.1。在没有 SSO 的情况下,整个站点正在使用 http/2。 Nginx 是 (1.15.0),来自 github 和当前 chrome (v71) 的 spnego 模块。

我在nginx中打开调试信息,有:

2019/01/07 14:39:11 [debug] 42129#42129: *2378 SSL ALPN supported by client: h2
2019/01/07 14:39:11 [debug] 42129#42129: *2378 SSL ALPN supported by client: http/1.1
2019/01/07 14:39:11 [debug] 42129#42129: *2378 SSL ALPN selected: h2
2019/01/07 14:39:11 [debug] 42132#42132: *2379 SSL ALPN supported by client: h2
2019/01/07 14:39:11 [debug] 42132#42132: *2379 SSL ALPN supported by client: http/1.1
2019/01/07 14:39:11 [debug] 42132#42132: *2379 SSL ALPN selected: h2
2019/01/07 14:39:11 [debug] 42129#42129: *2378 SSL_do_handshake: -1
2019/01/07 14:39:11 [debug] 42129#42129: *2378 SSL_get_error: 2
2019/01/07 14:39:11 [debug] 42129#42129: *2378 reusable connection: 0
2019/01/07 14:39:11 [debug] 42129#42129: *2378 SSL handshake handler: 0
2019/01/07 14:39:11 [debug] 42129#42129: *2378 ssl new session: 057AF550:32:184
2019/01/07 14:39:11 [debug] 42129#42129: *2378 SSL_do_handshake: 1
2019/01/07 14:39:11 [debug] 42129#42129: *2378 SSL: TLSv1.2, cipher: "ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD"
2019/01/07 14:39:11 [debug] 42129#42129: *2378 init http2 connection

在这个阶段没问题 - 它是 http2,但是模块发送 401 代码并要求提供凭据:

2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 header filter
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 push resources
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 output header: ":status: 401"
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 output header: "server: nginx"
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 output header: "date: Mon, 07 Jan 2019 13:41:05 GMT"
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 output header: "content-type: text/html; charset=utf-8"
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 output header: "content-length: 590"
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 output header: "www-authenticate: Negotiate"
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 output header: "strict-transport-security: max-age=63072000; includeSubDomains; preload"
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2:5 create HEADERS frame 000055B593338C60: len:133 fin:0
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http cleanup add: 000055B593338D58
2019/01/07 14:41:05 [debug] 42129#42129: *2378 http2 frame out: 000055B593338C60 sid:5 bl:1 len:133

至此 h2 似乎工作正常,之后 chrome 仅发送 http 1.1 alpn 以响应 401 页面:

2019/01/07 14:41:05 [debug] 42129#42129: *2378 reusable connection: 1
2019/01/07 14:41:05 [debug] 42129#42129: *2378 event timer del: 53: 8023593525
2019/01/07 14:41:05 [debug] 42129#42129: *2378 event timer add: 53: 180000:8023706453
2019/01/07 14:41:05 [debug] 42129#42129: *4179 SSL ALPN supported by client: http/1.1
2019/01/07 14:41:05 [debug] 42129#42129: *4179 SSL ALPN selected: http/1.1
2019/01/07 14:41:05 [debug] 42129#42129: *4179 SSL_do_handshake: -1
2019/01/07 14:41:05 [debug] 42129#42129: *4179 SSL_get_error: 2
2019/01/07 14:41:05 [debug] 42129#42129: *4179 reusable connection: 0
2019/01/07 14:41:05 [debug] 42129#42129: *4179 SSL handshake handler: 0
2019/01/07 14:41:05 [debug] 42129#42129: *4179 SSL_do_handshake: 1
2019/01/07 14:41:05 [debug] 42129#42129: *4179 SSL: TLSv1.2, cipher: "ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD"
2019/01/07 14:41:05 [debug] 42129#42129: *4179 SSL reused session
2019/01/07 14:41:05 [debug] 42129#42129: *4179 reusable connection: 1
2019/01/07 14:41:05 [debug] 42129#42129: *4179 http wait request handler

之后,整个域的所有内容都将在 http/1 中。我在 nginx 中配置了通配符服务器并测试了很多次——直到 auth h2,以及 auth http1 之后。现在我会将 auth 端点移动到另一个子域,这样 chrome 就不会强制应用程序使用 http1,但我仍在寻找修复方法。 我检查了 ssl、cert、ciphers - 在 http/1 和 http/2 上没有变化,它不是任何防病毒软件。 此外,我无法在登录后清除该状态和 FORCE http/2,唯一有帮助的是终止 chrome 进程。清除应用缓存没有帮助。

它适用于 IE 和 EDGE。默认情况下,Firefox 不支持 SSO 和策略。

如何强制 Chrome 将 http/2 用于域?如果无法在 auth 页面上执行此操作,我如何将其强制到除一个 url 之外的其他页面? 任何人都知道如何在开发工具中强制 chrome 重新协商 http/2。 此外,我在 chrome 中找不到任何关于从 http/2 切换到 v1

的日志和错误

这是 Chrome 中的已知错误。 Chrome 不支持 HTTP/2 上的 SSO,但也不支持某些 HTTP/1 和某些 HTTP/2 到同一域的连接,这是一个连锁反应。

在此处查看错误 https://bugs.chromium.org/p/chromium/issues/detail?id=832586

特别是底部的评论:

The root of the problem here is that the network stack currently does not support concurrent HTTP/1.1 and HTTP/2 connections to the same server. See issue 685741 comments 10 and 11 about opinions on this possibility.