有没有一种命令或服务可以告诉我网站是通过HTTP还是HTTP/2提供服务。
我找到了这个工具:HTTP/2测试 | 一个简单的HTTP/2.0测试工具,但它只告诉我我的网站是否支持HTTP/2,而不是它是否已经使用HTTP/2。
还有这个Chrome扩展程序:HTTP/2和SPDY指示器,它告诉我HTTP/2已在我的网站上启用,但据我所知,我的Apache版本甚至不支持它。
是否有任何确凿的方法?谢谢!
有没有一种命令或服务可以告诉我网站是通过HTTP还是HTTP/2提供服务。
我找到了这个工具:HTTP/2测试 | 一个简单的HTTP/2.0测试工具,但它只告诉我我的网站是否支持HTTP/2,而不是它是否已经使用HTTP/2。
还有这个Chrome扩展程序:HTTP/2和SPDY指示器,它告诉我HTTP/2已在我的网站上启用,但据我所知,我的Apache版本甚至不支持它。
是否有任何确凿的方法?谢谢!
Apache不需要支持它。Chrome扩展程序读取HTTP头来确定。
另一种方法是简单地查看Chrome或Firefox中的网络选项卡>标题>响应标头>查看源文件。可以在那里查看标题。它应该读取"HTTP/2"或某种我现在无法回忆起的类型。
最简单的方法是使用curl -I <your site>
,这将把HTTP响应放在第一行。
HTTP/2.0 200
server:nginx
date:Fri, 29 Apr 2016 14:31:40 GMT
content-type:text/html; charset=utf-8
content-length:7629
last-modified:Thu, 07 Apr 2016 02:41:08 GMT
....
对于使用 Nginx 的人来说,你可以查看访问日志,通常位于 /var/log/nginx/access.log
,并查找类似于以下的行:
167.220.232.9 - - [12/Feb/2018:15:09:04 +0800] "GET / HTTP/2.0" 200 2546 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
--http2
或--http2-prior-knowledge
。这将强制网站使用HTTP/2.0:--http2-prior-knowledge
(HTTP) Tells curl to issue its non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade. It requires
prior knowledge that the server supports HTTP/2 straight away. HTTPS requests will still do HTTP/2 the
standard way with negotiated protocol version in the TLS handshake.
--http2-prior-knowledge requires that the underlying libcurl was built to support HTTP/2. This option
overrides --http1.1 and -0, --http1.0 and --http2. Added in 7.49.0.
--http2
(HTTP) Tells curl to use HTTP version 2.
See also --no-alpn. --http2 requires that the underlying libcurl was built to support HTTP/2. This option
overrides --http1.1 and -0, --http1.0 and --http2-prior-knowledge. Added in 7.33.0.
mod_http2
可在 Apache 2.4.17 版本及更高版本中使用。您必须使用最新的 OpenSSL 1.0.2(最好是最新的 OpenSSL 1.0.2h,很快将推出1.1.0)。您可以在此处找到更多详细信息:https://icing.github.io/mod_h2/howto.html。为什么您看到更新您的 Web 服务器到最新的 2.4.20 版本存在问题?您是否预计软件存在兼容性问题?您可以使用 IE 开发人员工具或 Chrome 开发人员工具(只需使“协议”列可见),清除缓存(非常重要!)并查看网络跟踪中的 HTTP2 或 h2。您可以先在 cdnjs.com 上进行相同的测试。 - Olegmod_http2
,并想要安装它,但我使用的是CentOS,其最新的预打包版本Apache是2.4.6(就像你所说的,不支持mod_http2
)。我认为升级到2.4.17的唯一方法是从头开始编译Apache,但我不确定是否想这样做。我可能只能等待CentOS推出更新。 - Vadim