Skip to content

Nginx 경고 대응 - the "listen ... http2" directive is deprecated #110

@ibin79

Description

@ibin79

Nginx 1.25.1 이후, http2 설정 경고 - the "listen ... http2" directive is deprecated

[root@php79 ~]# nginx -v
nginx version: nginx/1.26.2

[root@php79 ~]# nginx -t
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/conf.d/php79.conf:52

참고) 설정 테스트 (-t) 시 경고(warn)만 있고, nginx 시작은 가능합니다.

1.25.1 이후 해결 방법

이미 추가된 사이트는 nginx 사이트.conf 에서 http2 구문만 수정하면 됩니다.

  • http2 선언된 설정 파일 검색
[root@php79 ~]# grep http2 /etc/nginx/conf.d/*.conf

    listen 443 ssl http2;
  • 다음처럼 listen 에서 http2 삭제후, 다음 라인에 http2 on 추가
    listen 443 ssl; 
    http2 on;

https://nginx.org/en/docs/http/ngx_http_v2_module.html

주의) 1.24 등 이전 버전에서 http2 on 미지원

1.24 버전에서 http2 on 설정을 추가하면 다음처럼 Nginx 가 시작되지 않는 장애가 생깁니다.

[root@php79 ~]# nginx -v
nginx version: nginx/1.24.0

[root@php79 ~]# nginx -t
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /etc/nginx/conf.d/php79.conf:74
nginx: [emerg] unknown directive "http2" in /etc/nginx/conf.d/php79.conf:75
nginx: configuration file /etc/nginx/nginx.conf test failed

[root@php79 ~]# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

stack 개선

  • stack 1.5.0 에서 기본 템플릿을 nginx 1.25.1 용으로 분기 예정. letsencrypt/template-server.conf

참고) 1.25.1 변경 로그

hanges with nginx 1.25.1                                        13 Jun 2023

    *) Feature: the "http2" directive, which enables HTTP/2 on a per-server
       basis; the "http2" parameter of the "listen" directive is now
       deprecated.

http://nginx.org/en/CHANGES-1.26

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions