LoginSignup
5
3

More than 5 years have passed since last update.

Nginx で http2 を使う

Last updated at Posted at 2017-12-27

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
を編集します。

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3