개요
Nginx에서 http2 기능을 켜는 방법을 정리한다.
버전 확인
$ nginx -v
nginx version: nginx/1.22.1
http2 모듈 설치여부 확인 방법
nginx -V 2>&1 | tr ' ' '\n' | grep 'http'
--with-http_v2_module
가 보인다면 http2 모듈이 있는 것이다.
http2 켜는 방법
- nginx 설정파일(conf파일)에서 다음과 같이 http2 지시자를 입력하고 값으로 on을 준다.
- 이 설정은 nginx 버전
1.25.1
부터 사용가능하다. - 참고로 http2를 사용하면서 TLS기능도 사용하려면 OpenSSL 버전 1.0.2 이상이 설치되어 있어야 한다.
server {
listen 443 ssl ;
http2 on; # 이 설정은 nginx 버전 `1.25.1`부터 사용가능하다. 그 이전 버전이라면 listen 지시자에 값으로 http2를 추가해주면 된다.
ssl_certificate server.crt;
ssl_certificate_key server.key;
}
참고
- https://nginx.org/en/docs/http/ngx_http_v2_module.html
- https://www.cyberciti.biz/faq/how-to-list-installed-nginx-modules-and-compiled-flags/