I'm trying to use http/2 on my website instead of http/1.1 which is already obsolete. I've already followed some tutorials but I'm not having success. I'll explain what I did.
I changed the following file vim /etc/apache2/sites-enabled/default-ssl.conf:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName gestao.centro.local
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLProtocol -all +TLSv1.1 +TLSv1.2
SSLCertificateFile /etc/ssl/certs/gestaocentrolocal3.cer
SSLCertificateKeyFile /etc/ssl/private/gestaocentrolocal2.key
SSLCACertificateFile /etc/ssl/certs/centro64.cer
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
Protocols h2 h2c http/1.1
</VirtualHost>
Where I added the following lines:
SSLProtocol -all +TLSv1.1 +TLSv1.2 Protocols h2 h2c http/1.1
When I execute the following line curl --http2 https://gestao.centro.local -I I get the following result:
HTTP/1.1 200 OK Date: Mon, 26 Feb 2024 12:16:41 GMT Server: Apache/2.4.41 (Ubuntu) Upgrade: h2,h2c Connection: Upgrade Last-Modified: Fri, 24 Nov 2023 10:54:06 GMT ETag: "8d5-60ae3c573e0d0" Accept-Ranges: bytes Content-Length: 2261 Vary: Accept-Encoding Content-Type: text/html
Still not using HTTP/2 but HTTP/1.1.
If I execute this line curl -I -v --tlsv1.2 --tls-max 1.2 https://gestao.centro.local I get the following result:
`Trying 192.168.0.22:443...
- TCP_NODELAY set
- Connected to gestao.centro.local (192.168.0.22) port 443 (#0)
- ALPN, offering h2
- ALPN, offering http/1.1
- successfully set certificate verify locations:
- CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs
- TLSv1.2 (OUT), TLS handshake, Client hello (1):
- TLSv1.2 (IN), TLS handshake, Server hello (2):
- TLSv1.2 (IN), TLS handshake, Certificate (11):
- TLSv1.2 (IN), TLS handshake, Server key exchange (12):
- TLSv1.2 (IN), TLS handshake, Server finished (14):
- TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
- TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
- TLSv1.2 (OUT), TLS handshake, Finished (20):
- TLSv1.2 (IN), TLS handshake, Finished (20):
- SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
- ALPN, server accepted to use http/1.1
- Server certificate:
- subject: C=PT
- start date: Apr 1 13:31:18 2022 GMT
- expire date: Mar 31 13:31:18 2024 GMT
- subjectAltName: host "gestao.centro.local" matched cert's "gestao.centro.local"
- issuer: DC=local; DC=centro; CN=rad
- SSL certificate verify ok.
HEAD / HTTP/1.1 Host: gestao.centro.local User-Agent: curl/7.68.0 Accept: /
- Mark bundle as not supporting multiuse < HTTP/1.1 200 OK HTTP/1.1 200 OK < Date: Mon, 26 Feb 2024 12:17:40 GMT Date: Mon, 26 Feb 2024 12:17:40 GMT < Server: Apache/2.4.41 (Ubuntu) Server: Apache/2.4.41 (Ubuntu) < Upgrade: h2,h2c Upgrade: h2,h2c < Connection: Upgrade Connection: Upgrade < Last-Modified: Fri, 24 Nov 2023 10:54:06 GMT Last-Modified: Fri, 24 Nov 2023 10:54:06 GMT < ETag: "8d5-60ae3c573e0d0" ETag: "8d5-60ae3c573e0d0" < Accept-Ranges: bytes Accept-Ranges: bytes < Content-Length: 2261 Content-Length: 2261 < Vary: Accept-Encoding Vary: Accept-Encoding < Content-Type: text/html Content-Type: text/html
- Connection #0 to host gestao.centro.local left intact `
I can't understand if I already have HTTP/2 configured correctly and my website already uses it or if I still need some steps to use it.
When I do a Lighthouse report in the Google Chrome console I receive this information:
Use HTTP/2 27 requests not served via HTTP/2