Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
754 views
in Technique[技术] by (71.8m points)

ssl - Enabling http/2 in Apache 2.4 does not work

We are trying to enable http/2 on Apache 2.4, but with no success. The server OS is FreeBSD 11.2, and the OpenSSL version is 1.0.2o.

We have a real and valid SSL Certificate with the rating A+ at Qualys SSL Server Test.

No errors in log files, the server restarts without no problems or errors. Access website with https:// works, but browser always downgrades to http/1.1.

We have this in our virtual section:

<Directory />
    Require         all granted
    AllowOverride   All
    SSLOptions      +StdEnvVars
</Directory>

<FilesMatch ".(cgi|shtml|phtml|php)$">
    SSLOptions      +StdEnvVars
</FilesMatch>

H2Direct on
Protocols h2 h2c http/1.1

Options                    None
SSLEngine                  On
SSLHonorCipherOrder        On
SSLSessionTickets          Off
SSLCompression             Off
SSLCipherSuite             "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"
SSLProtocol                All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1

SSLCertificateFile          "/usr/local/www/apache24/certs/server.crt"
SSLCertificateKeyFile       "/usr/local/www/apache24/certs/server.key"
SSLCertificateChainFile     "/usr/local/www/apache24/certs/intermediate.crt"

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff

---UPDATE---

root@srv04:/usr/home/user # httpd -V
Server version: Apache/2.4.35 (FreeBSD)
Server built:   unknown
Server's Module Magic Number: 20120211:82
Server loaded:  APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     prefork
threaded:     no
forked:     yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses disabled)
-D APR_USE_FLOCK_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/usr/local"
-D SUEXEC_BIN="/usr/local/bin/suexec"
-D DEFAULT_PIDLOG="/var/run/httpd.pid"
-D DEFAULT_SCOREBOARD="/var/run/apache_runtime_status"
-D DEFAULT_ERRORLOG="/var/log/httpd-error.log"
-D AP_TYPES_CONFIG_FILE="etc/apache24/mime.types"
-D SERVER_CONFIG_FILE="etc/apache24/httpd.conf"

---ALPN FROM QUALSYS---

ALPN    Yes   http/1.1

---CHROME---

Chrome 49 / XP SP3 RSA 2048 (SHA256) TLS 1.2 > http/1.1     TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ECDH secp256r1  FS
Chrome 69 / Win 7 R RSA 2048 (SHA256) TLS 1.2 > http/1.1    TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ECDH secp256r1  FS
Chrome 70 / Win 10 RSA 2048 (SHA256) TLS 1.2 > http/1.1     TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ECDH secp256r1  FS
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Apache does not support HTTP/2 with prefork MPM. This was added in 2.4.27:

*) COMPATIBILITY: mod_http2: Disable and give warning when using Prefork. The server will continue to run, but HTTP/2 will no longer be negotiated. [Stefan Eissing]

The Prefork MPM is basically incompatible with the way HTTP/2 is implemented. There should be a warning in your error logs after restart telling you this.

Prefork is also a very old MPM that is slow, so those sites that want HTTP/2 probably shouldn't be using it anyway. It should only really be used if you are running non-threadsafe PHP applications (threadsafe ones should move to Event MPM and php-fm (which is basically how Nginx runs as it does not offer a prefork equivalent). Unfortunately it is also the default on many Apache installs (just i case people use thread-unsafe PHP applications?), and often you cannot change it without downloading and recompiling it.

More info on MPMs here: https://serverfault.com/questions/383526/how-do-i-select-which-apache-mpm-to-use


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...