LoginSignup
0
0

More than 3 years have passed since last update.

Amazon Lightsail + NginxでHTTP/2を有効にする

Last updated at Posted at 2021-03-18

本題について

Amazon LightsailでNginxを利用していますが、HTTPバージョンが1.1でした。
※以下図、ChromeのデベロッパーツールProtocolでは"http/1.1"と表示
HTML 5 Shooting Game 2021-03-18 15-19-05.png
Lightsail上でのNginxにおいて、HTTP/2のアップデート方法を検索したのですが、意外に見つからず。
学習がてらメモ要素も含みつつ、手順をここに記載します。

設定自体は大変簡単でした。

環境

  • サーバ:AWS Lightsail(一番安い3.5ドル/月プラン)
  • ウェブサーバーアプリ:Nginx(バージョン nginx/1.16.0)
  • HTTPS設定済 Screen Shot 2021-03-18 at 17.18.33.png

1.Nginxのconfで以下を設定

Nginxのconfファイルにて、listen箇所にhttp2を追加するだけでした。

conf

# HTTPS server
server {
  listen 443 ssl http2;
  server_name  example.com;

  ・・・
}

2.Nginx再起動

$ sudo /opt/bitnami/ctlscript.sh restart nginx

以下図より、デベロッパーツールにて、Protocolに"h2"と表示されました。
HTML 5 Shooting Game 2021-03-18 15-57-17.png

参考

0
0
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
0
0