GrepBoard/매뉴얼
605 편 ·

listen ... http2 directive is deprecated

·시험 환경 nginx 1.30.6·1.31.8 (Docker) · Ubuntu 24.04 nginx 1.24.0 · 2026-10·시험 범위 ↓·6 단계

nginx 1.25.1+ 의 listen ... http2 directive is deprecated 경고는 http2 를 빼고 server 마다 http2 on; 을 넣으면 사라집니다. 1.24 에선 오류.

output
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/conf.d/default.conf:2

nginx 1.25.1 부터 listen 443 ssl http2; 의 http2 매개변수가 폐기 예정이 되어 나오는 경고입니다. listen 줄에서 http2 를 지우고 같은 server 블록에 http2 on; 한 줄을 넣으면 사라집니다. 경고일 뿐이라 nginx -t 는 성공하고 HTTP/2 도 그대로 동작합니다.

[1] 쓰는 판부터 확인합니다. 고치는 방법이 판에 따라 갈립니다.

console
$ nginx -v
판listen ... http2http2 on;
1.25.0 이하(Ubuntu 24.04 의 1.24.0 포함)경고 없음**unknown directive "http2" 오류**
1.25.1 이상(공식 stable 1.30.6 · mainline 1.31.8, Ubuntu 26.04 의 1.28.3)경고정상

nginx 변경 기록은 1.25.1(2023-06-13)에 "http2 지시어를 추가하고 listen 의 http2 매개변수를 폐기 예정으로 한다"고 적습니다. Ubuntu 24.04 에서 이 경고를 처음 보는 때는 nginx.org 패키지나 공식 Docker 이미지로 바꿨을 때, 또는 26.04 로 올렸을 때입니다.

[2] 경고가 가리키는 줄을 모두 찾습니다. 경고는 http2 가 붙은 listen 줄마다 하나씩 나오므로, IPv4·IPv6 두 줄이 있으면 두 번 나옵니다. include 된 파일까지 한 번에 보려면 nginx -T 를 씁니다.

console
$ sudo nginx -T 2>/dev/null | grep -nE "^# configuration file|listen .*http2"

[3] listen 에서 http2 를 빼고 http2 on; 을 넣습니다. 고치기 전에 사본을 만듭니다(sudo cp -a /etc/nginx /etc/nginx.bak).

/etc/nginx/conf.d/default.conf
server {  listen 443 ssl;  listen [::]:443 ssl;  http2 on;    server_name example.com;    ssl_certificate     /etc/nginx/certs/cert.pem;    ssl_certificate_key /etc/nginx/certs/key.pem;}

http2 지시어의 문맥은 http, server 입니다. 모든 사이트에 켜려면 http 블록에 한 번 써도 됩니다.

[4] 같은 포트를 쓰는 **다른 server 블록도 모두** 바꿉니다. 하나만 고치면 남은 블록 때문에 경고가 계속 납니다. 두 번째 블록에 listen 443 ssl http2; 가 남은 설정의 결과입니다.

output
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/conf.d/default.conf:10nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

반대로 listen 에서 http2 를 지우기만 하고 어떤 블록에는 http2 on; 을 넣지 않으면, 그 사이트만 HTTP/1.1 로 떨어집니다. 옛 방식은 그 주소·포트 전체에 HTTP/2 를 켰지만 http2 on; 은 server 단위입니다. 443 에 두 사이트를 두고 example.com 에만 http2 on; 을 넣어 본 결과입니다.

console
$ curl -sk --http2 -o /dev/null -w '%{http_version}\n' --resolve example.com:443:127.0.0.1 https://example.com/2$ curl -sk --http2 -o /dev/null -w '%{http_version}\n' --resolve www.example.com:443:127.0.0.1 https://www.example.com/1.1

경고는 사라졌는데 일부 사이트가 HTTP/2 를 잃는 경우이므로, 블록마다 넣었는지 [6]으로 확인합니다.

[5] 검사하고 다시 읽힙니다. 고친 설정은 경고 없이 통과합니다.

console
$ sudo nginx -t && sudo systemctl reload nginx
output
nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

Ubuntu 24.04 의 1.24.0 에서 같은 고친 설정을 검사하면 이렇게 실패합니다. 이때는 http2 on; 을 지우고 listen 443 ssl http2; 로 되돌립니다(1.24 에서는 그쪽이 맞는 문법이고 경고도 없습니다).

output
nginx: configuration file /etc/nginx/nginx.conf test failed

[6] 실제로 HTTP/2 로 응답하는지 봅니다. 사이트마다 이름을 바꿔 확인합니다.

console
$ curl -sk --http2 -I https://example.com/
output
HTTP/2 200 server: nginx/1.30.6

첫 줄이 HTTP/2 면 됩니다. HTTP/1.1 이면 그 server 블록에 http2 on; 이 없거나, 앞단의 프록시·CDN 이 따로 연결을 맺고 있는 것입니다.

자체 서명 인증서로 HTTPS 를 시험하는 법은 nginx 자체 서명 인증서, Ubuntu 패키지 판 확인은 nginx 설치 편을 봅니다.

Nginx 로그를 브라우저에서 바로 분석 ↗ — 아무것도 올라가지 않습니다.

#nginx#http2#deprecated#nginx-t