Skip to content

Instantly share code, notes, and snippets.

@nullx5
Last active April 22, 2025 02:44
Show Gist options
  • Save nullx5/32cc7c619ee9e5f572c1f14b7983766a to your computer and use it in GitHub Desktop.
Save nullx5/32cc7c619ee9e5f572c1f14b7983766a to your computer and use it in GitHub Desktop.

Configurar HTTP2 en apache

HTTP/2 solo se usa sobre HTTPS.

Herramientas para verificar si un sitio usa HTTP/2:

🔍 https://tools.keycdn.com/http2-test

🔍 https://www.ssllabs.com/ssltest/

Característica HTTP/1.1 HTTP/2
Protocolo Texto plano Binario
Multiplexación ❌ No (una petición por conexión) ✅ Sí (varias peticiones en paralelo)
Compresión de encabezados ❌ No ✅ Sí (HPACK)
Pipelining ✅ Sí (limitado y con problemas) ❌ No necesario (usa multiplexación)
Server Push ❌ No ✅ Sí
Prioridades de recursos ❌ No ✅ Sí
Uso de conexiones Múltiples por dominio Una sola por dominio
Seguridad (TLS) Opcional Recomendado (obligatorio en navegadores)
Eficiencia Menor (más latencia, más conexiones) Mayor (menos latencia, mejor uso de red)
Compatibilidad Universal Navegadores modernos

curl -I --http2 https://www.crummy.com HTTP/1.1 200 OK

curl -I --http2 https://gcc.gnu.org/ HTTP/2 200

curl -I --http2 https://github.com HTTP/2 200

curl -I --http2 -k https://localhost/ HTTP/2 200

sudo a2enmod ssl
sudo a2enmod http2

a2query -m
apache2ctl -M 

sudo nvim /etc/apache2/apache2.conf
Protocols h2 http/1.1

sudo nvim /etc/apache2/sites-available/default-ssl.conf
SSLEngine on
SSLCertificateFile    /home/blessed/certificado-autofirmado.crt
SSLCertificateKeyFile /home/blessed/clave-privada.key

sudo a2ensite default-ssl.conf
a2query -s

sudo systemctl reload apache2
sudo systemctl restart apache2

curl -I -k --http2 https://localhost/

Sin Certificados HTTPS

curl -I --http2 http://localhost/                                                                                                       
HTTP/1.1 101 Switching Protocols
Upgrade: h2c
Connection: Upgrade

HTTP/2 200 
last-modified: Wed, 16 Apr 2025 06:57:44 GMT
etag: W/"29af-632dfcd552cbf"
accept-ranges: bytes
content-length: 10671
vary: Accept-Encoding
content-type: text/html
date: Sun, 00 Jan 1900 00:00:00 GMT
server: Apache/2.4.52 (Ubuntu)

Con certificados HTTPS


curl -I --http2 -k https://localhost/                                                                                                
HTTP/2 200 
last-modified: Wed, 16 Apr 2025 06:57:44 GMT
etag: "29af-632dfcd552cbf"
accept-ranges: bytes
content-length: 10671
vary: Accept-Encoding
content-type: text/html
date: Wed, 16 Apr 2025 07:25:08 GMT
server: Apache/2.4.52 (Ubuntu)

@nullx5
Copy link
Author

nullx5 commented Apr 22, 2025

Paths recomendados para certificados

Por convención en sistemas Linux:

Certificado público (.crt o .pem):
/etc/ssl/certs/tu_dominio.crt

Clave privada (.key):
/etc/ssl/private/tu_dominio.key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment