방금 작은 Apache VM을 설정하고 문서에 설명된 대로 HTTP/2 모듈을 활성화했습니다(HTTP/2 가이드). 테스트하려면 브라우저가 아닌 클라이언트를 사용하는 것이 좋습니다 curl
. 그런데 몇 가지 이상한 문제를 발견했습니다.
HTTP2( ) curl
를 사용하라는 지시를 받으면 Apache는 일반적인 한 줄 대신 두 줄을 작성합니다. 또한 첫 번째 줄의 날짜는 완전히 잘못되었으며(때로는 비어 있을 수도 있음) 두 번째 줄의 프로토콜은 예상대로 HTTP/2가 아닌 HTTP/1.1입니다.curl --http2
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"
이러한 문제에 대한 더 많은 예는 다음과 같습니다 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"
curl
HTTP/1.0 또는 HTTP/1.1로 다시 전환하면 이 문제가 발생하지 않습니다.
어떤 아이디어가 있나요?
디버깅 정보
가상 머신 설정
가상화:
libvirt
KVM 관리운영 체제:Debian 11(CLI 전용, DE 없음)
일:
[X] web server [X] SSH server
참고: 다른 모든 항목은 선택 취소되어 있습니다.
아파치:모듈은
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 연결임을 알 수 있습니다. 이러한 관점에서 보면 로그 항목이 두 개 있는 것이 합리적입니다.
~에서HTTP/2 FAQ:
HTTP/1.1을 구현하지 않고 HTTP/2를 구현할 수 있나요?
네, 대부분요.
TLS(h2)를 통한 HTTP/2의 경우 http1.1 ALPN 식별자를 구현하지 않으면 HTTP/1.1 기능을 지원할 필요가 없습니다.
TCP를 통한 HTTP/2(h2c)의 경우 초기 업그레이드 요청을 구현해야 합니다.
누구세요아니요TLS를 하고 있으니 h2c
HTTP/1.1 요청은 불가피합니다.
답변2
Apache의 http2 모듈에서 버그가 발생했습니다. 2023년 11월 22일에 이 문제를 보고했고 다음날 수정되었습니다.날짜가 깨진 h2c curl --http2
· Issue #272 · icing/mod_h2
개발자에 따르면 에는 req->request_time = apr_time_now();
a가 없습니다 mod_http2/h2_request.c
.