AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1077086
Accepted
hyjinx
hyjinx
Asked: 2021-09-10 04:26:53 +0800 CST2021-09-10 04:26:53 +0800 CST 2021-09-10 04:26:53 +0800 CST

在 Debian 9.13 上的 apache2 v2.4.25 中启用了 HTTP/2 支持,但测试显示不支持 HTTP/2

  • 772

我正在尝试配置 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 测试网站上测试了该网站,但每次都失败。

debian apache2 http2
  • 1 1 个回答
  • 340 Views

1 个回答

  • Voted
  1. Best Answer
    djdomi
    2021-09-11T02:17:57+08:002021-09-11T02:17:57+08:00

    升级到支持的操作系统

    您使用了 Debian Stretch,主要支持是恕我直言,已经 EOL。(生命周期结束)
    安全补丁在 2022 年 6 月 30 日之前仍然可用。

    更改 Apache 处理模块

    sudo a2dismod mpm_prefork
    sudo a2enmod mpm_event
    

    启用 SSL 和 http2 模块

    sudo a2enmod ssl  
    sudo a2enmod http2  
    

    启用 http2 支持全局或通过虚拟主机

    添加到 Apache2.conf:

    Protocols h2 http/1.1
    

    或编辑虚拟主机并添加 协议 h2 http/1.1

    <VirtualHost *:443>
      ServerName example.com
      ServerAlias www.example.com
      DocumentRoot /var/www/public_html/example.com
      SSLEngine on
      SSLCertificateKeyFile /path/to/private.pem
      SSLCertificateFile /path/to/cert.pem
      SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
      Protocols h2 http/1.1 #add this here
    </VirtualHost>
    

    提醒重新加载 Apache 服务器。

    sudo systemctl restart apache2
    

    要获取所有 php 版本,您可以查看我的 bash 脚本

    https://raw.githubusercontent.com/djdomi/php-install/master/run.sh
    

    参考

    关于本指南

    • 0

相关问题

  • 关闭 FTP

  • 如何在同一台电脑上从 putty 连接 debian vmware

  • debian- 文件到包的映射

  • Debian Ubuntu 网络管理器错误 [关闭]

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve