Ubuntu 26.04

Apache2 : mod_http2 の設定2026/05/25

 

[mod_http2] を設定して HTTP/2 を有効にします。

[1]

事前に SSL/TLS の設定を実施しておきます。
(クライアント側の多くの Web ブラウザーは HTTPS でのみ HTTP/2 をサポート)

[2] [mod_http2] の設定です。
設定をしたい対象のバーチャルホストごとに設定可能です。
なお、[mod_http2] は [prefork] では有効にならないため、Apache httpd の動作モードが、Ubuntu デフォルトの [event] か [worker] である必要があります。
# 設定したい任意のバーチャルホスト定義内に設定

root@www:~#
vi /etc/apache2/sites-enabled/dlp.srv.world.conf
# [Protocols] 行を追記

<VirtualHost *:443>
    Protocols h2 http/1.1
    DocumentRoot /var/www/dlp
    ServerName dlp.srv.world:443
    ServerAdmin webmaster@dlp.srv.world
    ErrorLog /var/log/apache2/dlp_ssl_error_log
    CustomLog /var/log/apache2/dlp_ssl_access_log combined
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/dlp.srv.world/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/dlp.srv.world/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/dlp.srv.world/chain.pem
</VirtualHost>

<Directory "/var/www/dlp">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

root@www:~#
a2enmod http2

Enabling module http2.
To activate the new configuration, you need to run:
  systemctl restart apache2

root@www:~#
systemctl restart apache2
# アクセスして確認
# [HTTP/2] となっていれば OK

root@www:~#
curl -I https://dlp.srv.world/

HTTP/2 200
last-modified: Mon, 25 May 2026 00:19:52 GMT
etag: "29b0-6529956553738"
accept-ranges: bytes
content-length: 10672
vary: Accept-Encoding
content-type: text/html
date: Mon, 25 May 2026 05:42:39 GMT
server: Apache/2.4.66 (Ubuntu)
関連コンテンツ