デバッグ情報

デバッグ情報

ちょっと小さいApache VMを設定し、ドキュメントの説明に従ってHTTP / 2モジュールを有効にしました(HTTP/2 ガイド)。テストするには、ブラウザではなくクライアントを使用することをお勧めしますcurl。ところで、いくつかの奇妙な問題を発見しました。

HTTP2()curlを使用するように指示された場合、Apacheは通常の1行ではなく2行を作成します。さらに、最初の行の日付は完全に間違っており(時には空白になる可能性があります)、2行目のプロトコルは期待どおりHTTP / 2ではなくHTTP / 1.1です。curl --http2access.log

192.168.122.1 - - [31/Dec/1969:21:00:00 -0300] "GET / HTTP/2.0" 200 10922 "-" "curl/7.74.0"
192.168.122.1 - - [19/Mar/2023:04:55:34 -0300] "GET / HTTP/1.1" 101 10967 "-" "curl/7.74.0"

これらの問題のより多くの例は次のとおりですaccess.log

192.168.122.1 - -  "GET / HTTP/2.0" 200 10922 "-" "curl/7.74.0"
192.168.122.1 - - [19/Mar/2023:06:26:31 -0300] "GET / HTTP/1.1" 101 10967 "-" "curl/7.74.0"
192.168.122.1 - -  "GET / HTTP/2.0" 200 10922 "-" "curl/7.74.0"
192.168.122.1 - - [19/Mar/2023:06:26:36 -0300] "GET / HTTP/1.1" 101 10967 "-" "curl/7.74.0"
192.168.122.1 - - [00/Jan/1900:00:00:00 +0000] "GET / HTTP/2.0" 200 10922 "-" "curl/7.74.0"
192.168.122.1 - - [19/Mar/2023:06:26:39 -0300] "GET / HTTP/1.1" 101 10967 "-" "curl/7.74.0"
192.168.122.1 - - [00/Jan/1900:00:00:00 +0000] "GET / HTTP/2.0" 200 10922 "-" "curl/7.74.0"
192.168.122.1 - - [19/Mar/2023:06:26:48 -0300] "GET / HTTP/1.1" 101 10950 "-" "curl/7.74.0"

curlHTTP/1.0 または HTTP/1.1 に切り替えると、この問題は発生しません。

どんなアイデアがありますか?


デバッグ情報

仮想マシンの設定

  • 仮想化: libvirtKVMの管理

  • オペレーティングシステム:Debian 11(CLIのみ、DEなし)

  • 仕事:

      [X] web server
      [X] SSH server
    

    注:他のすべての項目は選択解除されています。

  • Apache:モジュールはhttp2デフォルト設定で有効になります。

      root@debian:~# apachectl -M
      AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
      Loaded Modules:
       [...]
       http2_module (shared)
    

    注:http2モジュールはアクティブなモジュールには影響しませんprefork。ただし、preforkモジュールはデフォルトで無効になっています。

カールによるHTTP 1.0

root@debian:~# curl -v -s --http1.0 http://192.168.122.190/ > /dev/null

*   Trying 192.168.122.190:80...
* Connected to 192.168.122.190 (192.168.122.190) port 80 (#0)
> GET / HTTP/1.0
> Host: 192.168.122.190
> User-Agent: curl/7.74.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Sun, 19 Mar 2023 07:44:03 GMT
< Server: Apache/2.4.54 (Debian)
< Upgrade: h2,h2c
< Connection: Upgrade, close
< Last-Modified: Fri, 17 Mar 2023 08:12:30 GMT
< ETag: "29cd-5f7142383c2f1"
< Accept-Ranges: bytes
< Content-Length: 10701
< Vary: Accept-Encoding
< Content-Type: text/html
< 
{ [10701 bytes data]
* Closing connection 0


root@debian:~# tail -f /var/log/apache2/access.log
[...]
192.168.122.1 - - [19/Mar/2023:04:44:03 -0300] "GET / HTTP/1.0" 200 11001 "-" "curl/7.74.0"

カールによるHTTP 1.1

root@debian:~# curl -v -s --http1.1 http://192.168.122.190/ > /dev/null

*   Trying 192.168.122.190:80...
* Connected to 192.168.122.190 (192.168.122.190) port 80 (#0)
> GET / HTTP/1.1
> Host: 192.168.122.190
> User-Agent: curl/7.74.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Sun, 19 Mar 2023 07:47:42 GMT
< Server: Apache/2.4.54 (Debian)
< Upgrade: h2,h2c
< Connection: Upgrade
< Last-Modified: Fri, 17 Mar 2023 08:12:30 GMT
< ETag: "29cd-5f7142383c2f1"
< Accept-Ranges: bytes
< Content-Length: 10701
< Vary: Accept-Encoding
< Content-Type: text/html
< 
{ [6947 bytes data]
* Connection #0 to host 192.168.122.190 left intact


root@debian:~# tail -f /var/log/apache2/access.log
[...]
192.168.122.1 - - [19/Mar/2023:04:47:42 -0300] "GET / HTTP/1.1" 200 10994 "-" "curl/7.74.0"

カールによるHTTP 2.0

root@debian:~# curl -v -s --http2 http://192.168.122.190/ > /dev/null

*   Trying 192.168.122.190:80...
* Connected to 192.168.122.190 (192.168.122.190) port 80 (#0)
> GET / HTTP/1.1
> Host: 192.168.122.190
> User-Agent: curl/7.74.0
> Accept: */*
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAAQCAAAAAAIAAAAA
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 101 Switching Protocols
< Upgrade: h2c
< Connection: Upgrade
* Received 101
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 200 
< last-modified: Fri, 17 Mar 2023 08:12:30 GMT
< etag: W/"29cd-5f7142383c2f1"
< accept-ranges: bytes
< content-length: 10701
< vary: Accept-Encoding
< content-type: text/html
< date: Thu, 01 Jan 1970 00:00:00 GMT
< server: Apache/2.4.54 (Debian)
< 
{ [7099 bytes data]
* Connection #0 to host 192.168.122.190 left intact


root@debian:~# tail -f /var/log/apache2/access.log
[...]
192.168.122.1 - - [31/Dec/1969:21:00:00 -0300] "GET / HTTP/2.0" 200 10922 "-" "curl/7.74.0"
192.168.122.1 - - [19/Mar/2023:04:55:34 -0300] "GET / HTTP/1.1" 101 10967 "-" "curl/7.74.0"

カールによるHTTP 2.0(非TLS)

root@debian:~# curl -v -s --http2-prior-knowledge http://192.168.122.190/ > /dev/null

*   Trying 192.168.122.190:80...
* Connected to 192.168.122.190 (192.168.122.190) port 80 (#0)
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x561926605ce0)
> GET / HTTP/2
> Host: 192.168.122.190
> user-agent: curl/7.74.0
> accept: */*
> 
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 200 
< last-modified: Fri, 17 Mar 2023 08:12:30 GMT
< etag: "29cd-5f7142383c2f1"
< accept-ranges: bytes
< content-length: 10701
< vary: Accept-Encoding
< content-type: text/html
< date: Sun, 19 Mar 2023 07:59:47 GMT
< server: Apache/2.4.54 (Debian)
< 
{ [10701 bytes data]
* Connection #0 to host 192.168.122.190 left intact


root@debian:~# tail -f /var/log/apache2/access.log
[...]
192.168.122.1 - - [19/Mar/2023:04:59:47 -0300] "GET / HTTP/2.0" 200 10920 "-" "curl/7.74.0"

機能確認curl:

root@debian:~# curl -V
curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1n zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3
Release-Date: 2020-12-09
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

注: したがって、このcurlバージョンは HTTP/2 をサポートします。

ベストアンサー1

ApacheのHTTP / 2サブシステムでは、タイムスタンプが重大に破損しているように見えることに加えて、HTTP / 2接続がHTTP / 2にアップグレードされるHTTP / 1.1接続であることがわかります。この観点から見ると、ログエントリが2つあることが合理的です。

~からHTTP/2 FAQ:

HTTP/1.1を実装せずにHTTP/2を実装できますか?

はい、ほとんどです。

TLS(h2)を介したHTTP / 2の場合、http1.1 ALPN識別子を実装しない限り、HTTP / 1.1機能をサポートする必要はありません。

TCP経由のHTTP / 2(h2c)の場合は、最初のアップグレード要求を実装する必要があります。

誰ですかいいえTLSをしているので、h2cHTTP/1.1リクエストは避けられません。

おすすめ記事