https が使える状態のサーバーで、http2 が使えるようにしました。
nginx.conf の
server listen を次のように変更します。
http2 を加えるだけです。
server {
listen 443 ssl http2;
変更後、nginx を再起動します。
sudo systemctl restart nginx
変更前のヘッダー
HTTP/1.1 200 OK
Server: nginx/1.10.2
Date: Wed, 27 Dec 2017 08:40:56 GMT
Content-Type: text/html
Content-Length: 1958
Last-Modified: Tue, 14 Nov 2017 21:11:54 GMT
Connection: keep-alive
ETag: "5a0b5c1a-7a6"
Accept-Ranges: bytes
変更後のヘッダー
HTTP/2 200
server: nginx/1.10.2
date: Wed, 27 Dec 2017 08:42:57 GMT
content-type: text/html
content-length: 1958
last-modified: Tue, 14 Nov 2017 21:11:54 GMT
etag: "5a0b5c1a-7a6"
accept-ranges: bytes
ヘッダーを確認するスクリプト
curl -I https://example.com
Ubuntu の場合は、/etc/nginx/sites-available/default
を編集します。