


CodeIT repositoryを使用してApache/2.4.27, mod_http2 1.10.10, mod_ssl 2.4.27をインストールしました。
改めてCentOS 7.4の最小構成でインストールすると依存関係でエラーが発生したので、下記のコマンドでインストールしました。
1 2 |
# yum --disablerepo=* --enablerepo=CodeITmainline,base install httpd # yum --disablerepo=* --enablerepo=CodeITmainlineinstall mod_ssl |
今回のインストール後に行った設定ですが、取り敢えずHTTP/2で通信が行われることを最優先しているので、セキュリティなどは考慮していません。
- Setting Firewall
- Edit ssl.conf
- Sample index.html
- Start httpd
- Check HTTP/2
httpsを許可します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# firewall-cmd --permanent --add-service=https # firewall-cmd --reload success # firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: dhcpv6-client ssh https ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: |
/etc/httpd/conf.d/ssl.confに証明書の設定を行います。
ローカル証明書ではエラーになったので、今回はLet’s Encryptで取得した証明書を設定しました。
また”Protocols h2 http/1.1“はすでにssl.confに記述されていました。
1 2 3 4 5 6 7 8 |
Listen 443 https Protocols h2 http/1.1 SSLCertificateFile /etc/ssl/cert.pem SSLCertificateKeyFile /etc/ssl/privkey.pem SSLCertificateChainFile /etc/ssl/chain.pem <VirtualHost _default_:443> DocumentRoot "/var/www/html" ServerName centos7.rootlinks.net:443 |
注意:関係部分を抜粋しています。証明書のパスは環境に合わせて変更して下さい。
適当にindex.htmlを作成します。
1 |
# vi /var/www/html/index.html |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# systemctl start httpd # systemctl status httpd * httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2017-09-22 11:54:08 JST; 6s ago Docs: man:httpd.service(8) Main PID: 1540 (httpd) Status: "Processing requests..." CGroup: /system.slice/httpd.service |-1540 /usr/sbin/httpd -DFOREGROUND |-1541 /usr/sbin/httpd -DFOREGROUND |-1542 /usr/sbin/httpd -DFOREGROUND |-1543 /usr/sbin/httpd -DFOREGROUND `-1545 /usr/sbin/httpd -DFOREGROUND Sep 22 11:54:08 centos7.rootlinks.net systemd[1]: Starting The Apache HTTP Server... Sep 22 11:54:08 centos7.rootlinks.net systemd[1]: Started The Apache HTTP Server. |
curlで確認してみます。HTTP/2(h2)で通信が行われています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# curl --http2 -v https://centos7.rootlinks.net * Rebuilt URL to: https://centos7.rootlinks.net/ * Trying 192.168.1.1... * TCP_NODELAY set * Connected to centos7.rootlinks.net (192.168.1.1) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: none CApath: none * loaded libnssckbi.so * ALPN, server accepted to use h2 * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * Server certificate: * subject: CN=centos7.rootlinks.net * start date: Sep 21 13:06:00 2017 GMT * expire date: Dec 20 13:06:00 2017 GMT * common name: centos7.rootlinks.net * issuer: CN=Let's Encrypt Authority X3,O=Let's Encrypt,C=US * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0xe81e90) > GET / HTTP/2 > Host: centos7.rootlinks.net > User-Agent: curl/7.55.1 > Accept: */* > * Connection state changed (MAX_CONCURRENT_STREAMS updated)! < HTTP/2 200 < date: Fri, 22 Sep 2017 04:17:34 GMT < server: Apache/2.4.27 (centos) OpenSSL/1.0.2l < last-modified: Fri, 22 Sep 2017 03:00:18 GMT < etag: "13-559be68b3424b" < accept-ranges: bytes < content-length: 19 < content-type: text/html; charset=UTF-8 < Connections HTTP/2 * Connection #0 to host centos7.rootlinks.net left intact |
拍子抜けするほど簡単でした。
Google Chrome 61のデベロッパーツールで確認でもProtocolがh2になっていました。