问题
HTTP/2 does not seem to be running after what seems to be a proper installation.
I am running CentOS 7.
I installed the latest version of Apache, version httpd-2.4.35-5.el7.x86_64, and have been trying to get HTTP/2 working.
For this, I see that we need to have http2_module running. That is active and running. I believe to have confirmed this by running the command httpd -M
. http2_module (shared) is listed under those modules.
The next thing I know to do is add in Protocols h2 h2c http/1.1
above the <VirtualHost ...>
tag. I have done that as well.
Finally, I have CURLed my URL, and I am still getting HTTP/1.1.
CURL command: curl -vsko /dev/null --http2 https://www.thehomepainter.com
Brief response from the CURL:
GET / HTTP/1.1 Host: www.thehomepainter.com User-Agent: curl/7.64.0 Accept: /
< HTTP/1.1 200 OK
Partial from 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>
So the expected result is for HTTP/2 to work. However, it is not and I have no idea why.
回答1:
After scrapping through the error log I finally found the issue.
[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.
To solve, I edited /etc/httpd/conf.modules.d/00-mpm.conf
Comment out this line:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
And uncomment the bottom line:
LoadModule mpm_event_module modules/mod_mpm_event.so
Restart apache and then it works.
来源:https://stackoverflow.com/questions/54720116/http-2-configuration-not-running-after-mod-http2-enabled-and-protocols-set-in-co