首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在启用mod_http2并在conf文件中设置协议之后,HTTP/2配置没有运行

在启用mod_http2并在conf文件中设置协议之后,HTTP/2配置没有运行
EN

Stack Overflow用户
提问于 2019-02-16 05:13:56
回答 1查看 7K关注 0票数 5

HTTP/2似乎并不是运行在一个似乎是正确的安装之后。

我正在运行CentOS 7。

我安装了Apache的最新版本httpd-2.4.35-5.el7.x86_64,并一直试图使HTTP/2正常工作。

为此,我看到我们需要运行http2_module。这是活动的和运行的。我相信通过运行命令httpd -M已经证实了这一点。http2_module (共享)列在这些模块下面。

接下来我要做的就是在Protocols h2 h2c http/1.1标签上添加<VirtualHost ...>。我也这么做过。

最后,我有了CURLed我的URL,并且我仍然得到HTTP1.1。

CURL命令:curl -vsko /dev/null --http2 https://www.thehomepainter.com

卷曲的简短答复:

GET /HTTP1.1主机: www.thehomepainter.com用户-代理: curl/7.64.0接受:// < HTTP/1.1 200 OK

部分来自httpd.conf

代码语言:javascript
复制
Protocols h2 h2c http/1.1
<VirtualHost *:443>
    SSLEngine on
    ServerAdmin ### omitted ###
    ServerName thehomepainter.com
    ServerAlias www.thehomepainter.com
    DocumentRoot /var/www/html/
    Options -Indexes

    ProxyRequests off
    ProxyPreserveHost On
    AllowEncodedSlashes NoDecode

    ProxyPass "/" "http://localhost:3000/"
    ProxyPassReverse "/" "http://localhost:3000/"

    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Port "443"

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile ### omitted ###
    SSLCertificateKeyFile ### omitted ###
    SSLCertificateChainFile ### omitted ###

    # i have tried this here as well
    # Protocols h2 h2c http/1.1
</VirtualHost>

Protocols h2 h2c http/1.1
<VirtualHost *:80>
    ServerAdmin support@thedesignguis.com
    ServerName thehomepainter.com
    ServerAlias www.thehomepainter.com
    DocumentRoot /var/www/html
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =thehomepainter.com [OR]
    RewriteCond %{SERVER_NAME} =www.thehomepainter.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

    # i have tried this here as well
    # Protocols h2 h2c http/1.1
</VirtualHost>

因此,预期的结果是HTTP/2能够工作。然而,事实并非如此,我也不知道为什么。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-16 06:01:01

在浏览了错误日志之后,我终于发现了这个问题。

[http2:warn] [pid 7155] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.

为了解决这个问题,我编辑了/etc/httpd/con.Modes.d/00-mpm.conf

注释掉这一行:LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

并取消评论的底线:LoadModule mpm_event_module modules/mod_mpm_event.so

重新启动apache,然后它就能工作了。

票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54720116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档