http/2似乎在似乎是适当的安装后运行。
我正在运行Centos 7。
我安装了最新版本的Apache,版本httpd-2.4.35-5.el7.x86_64,并一直在尝试使http/2工作。
为此,我看到我们需要运行http2_module。那是活跃和运行的。我相信通过运行命令httpd -M
来确认这一点。http2_module(共享)在这些模块下列出。
我知道要做的接下来是在<VirtualHost ...>
标签上方添加Protocols h2 h2c http/1.1
。我也做了。
最后,我ed缩了我的URL,我仍然得到HTTP/1.1。
curl命令:curl -vsko /dev/null --http2 https://www.thehomepainter.com
卷发的简短响应:
获取/http/1.1 主持人:www.thehomepainter.com 用户代理:卷曲/7.64.0 接受:/
&lt;http/1.1 200 ok
httpd.conf
的部分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工作。但是,不是,我不知道为什么。
刮过错误日志后,我终于找到了问题。
[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/conf.modules.d/00-mpm.conf
评论这一行: LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
和不注重底线: LoadModule mpm_event_module modules/mod_mpm_event.so
重新启动apache,然后起作用。