我正在尝试配置 HTTP/2 支持,但出了点问题
我的服务器是运行 Debian 9.13(拉伸)服务器版本 Apache/2.4.25 的谷歌计算引擎 vm,并使用 OpenSSL 配置了 SSL 证书。当我运行openssl version
它报告版本 1.1.1g。运行 phpinfo();
时会报告 OpenSSL/1.0.2u
. PHP 版本 7.4.11 并且phpinfo();
还报告...
SSL_VERSION_INTERFACE -> mod_ssl/2.4.25
SSL_VERSION_LIBRARY -> OpenSSL/1.0.2u
SSL_PROTOCOL -> TLSv1.2
我按照此处的说明“在 Apache 中启用 HTTP/2 模块”和“在您的 Apache 虚拟主机中启用 HTTP/2”以及此处。这样做之后,当我运行命令时 apache2ctl -M | grep http2
,它会返回http2_module (shared)
启用 HTTP/2 支持的信号。但它不在生产中。
这是我的 apache2 虚拟主机配置文件中使用的行 /etc/apache2/sites-available/default-ssl.conf
<VirtualHost _default_:443>
Protocols h2 h2c http/1.1
...
curl -vso http2_debug.log --http2 https://pharealty.com/
这是使用成功下载页面的命令时的详细连接信息。
* Trying 35.236.101.224...
* TCP_NODELAY set
* Connected to pharealty.com (35.236.101.224) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [109 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [4036 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: CN=pharealty.com
* start date: Jul 10 01:53:04 2021 GMT
* expire date: Oct 8 01:53:03 2021 GMT
* subjectAltName: host "pharealty.com" matched cert's "pharealty.com"
* issuer: C=US; O=Let's Encrypt; CN=R3
* SSL certificate verify ok.
} [5 bytes data]
> GET / HTTP/1.1
> Host: pharealty.com
> User-Agent: curl/7.52.1
> Accept: */*
>
{ [5 bytes data]
< HTTP/1.1 200 OK
< Date: Wed, 08 Sep 2021 17:20:21 GMT
< Server: Apache
< Upgrade: h2,h2c
< Connection: Upgrade
< Set-Cookie: PHPSESSID=1mv9jqka4n7c7fb6qmtavfsgue; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< X-Pingback: https://pharealty.com/xmlrpc.php
< Link: <https://pharealty.com/wp-json/>; rel="https://api.w.org/"
< Link: <https://pharealty.com/wp-json/wp/v2/pages/48>; rel="alternate"; type="application/json"
< Link: <https://pharealty.com/>; rel=shortlink
< Set-Cookie: phaLandingPage=%2F; expires=Tue, 08-Mar-2022 17:20:21 GMT; Max-Age=15638400; path=/
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
{ [7 bytes data]
* Curl_http_done: called premature == 0
* Connection #0 to host pharealty.com left intact
看起来它一开始工作得很好,然后又恢复到 HTTP/1.1
据我所知,我有足够新的 OpenSSL 版本。尽管我之前提到的这个页面强烈推荐了高于 2.4.25 的 apache 版本,但我无法将 apache 更新到 2.4.25 以外的任何版本。
切换后是否需要设置新的 SSL 证书?是 apache 的版本导致问题的原因吗?
我已经在几个 http/2 测试网站上测试了该网站,但每次都失败。