[英]How do I know if my website is being served over HTTP or HTTP/2?
是否有命令或服務告訴我我的網站是通過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
....
您也可以嘗試--http2
或--http2-prior-knowledge
。 這些將強制webiste使用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.
對於使用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"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.