はじめに
Nginxの設定ファイル確認時に出た警告と、その対応について書きます。
環境
- Rocky Linux 9.4
- Nginx 1.26.0
警告の内容
Nginx 1.25.1でlisten ... http2
ディレクティブが非推奨になり、$ nginx -t
で設定ファイルを確認すると、以下のような警告が出ます。
$ sudo nginx -t
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in {confファイル名}:2
対処法
エラーメッセージの通り、http2
ディレクティブを設定します。
修正前
server {
listen 443 ssl http2;
...(後略)
}
修正後
server {
listen 443 ssl;
http2 on;
...(後略)
}
おわりに
上記の修正で問題なく$ nginx -t
が成功しました。
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
参考