Nginx로 HTTP/3 적용하기

빠게뜨·2023년 12월 4일
post-thumbnail

NGINX의 HTTP/3 지원

https://nginx.org/en/docs/quic.html

Support for QUIC and HTTP/3 protocols is available since 1.25.0. Also, since 1.25.0, the QUIC and HTTP/3 support is available in Linux binary packages.

The QUIC and HTTP/3 support is experimental, caveat emptor applies.

Nginx 는 1.25.0 버전 부터 QUIC와 HTTP/3 프로토콜을 지원합니다. 아직까지는 실험적인 기능입니다.

QUIC 지원을 제공하는 SSL 라이브러리

기존에 사용하던 OpenSSL은 QUIC에 대한 지원이 없기 때문에 QUIC를 사용 할 수 있는 다음 SSL 라이브러리 중 하나를 사용하는 것이 좋습니다.

  • BoringSSL
  • LibreSSL
  • QuicTLS

저는 이 중에서 LibreSSL을 설치하고 사용했습니다.

LibreSSL 설치

NGINX 설치

현재 최신 버전인 nginx-1.25.3 버전의 소스파일을 다운로드 후 압축해제 합니다.

cd /usr/local/src
wget https://nginx.org/download/nginx-1.25.3.tar.gz
tar -xvf nginx-1.25.3.tar.gz

HTTP3 모듈을 사용하기 위해 --with-http_v3_module 옵션과 함께 config를 진행합니다.

./configure \
    --sbin-path=/usr/local/nginx/nginx \
    --conf-path=/usr/local/nginx/nginx.conf \
    --pid-path=/usr/local/nginx/nginx.pid \
    --with-debug \
    --with-cc-opt="-I /usr/local/include" \
    --with-ld-opt="-L /usr/local/lib" \
    --with-http_ssl_module \
    --with-http_v2_module \
    --with-http_v3_module \
    --with-pcre

config가 완료되면 make, make install을 차례로 진행하여 설치를 완료합니다.

make
make install

설치시 따로 prefix를 지정하지 않았다면 /usr/local/nginx 경로에 설치가 됩니다.

nginx -V 명령으로 설치 정보를 확인합니다.

nginx version: nginx/1.25.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with LibreSSL 3.8.2
TLS SNI support enabled
configure arguments: --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-debug --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-pcre

설치가 잘 완료되었다면 nginx.conf의 내용을 수정해야 합니다. 저는 node front-end 서버로 proxy_pass 하는 설정을 추가했습니다.

server {
        listen       443 quic reuseport;
        listen       443 ssl;
        server_name  /* domain.example.com */;

        ssl_protocols                   TLSv1.3;
        ssl_certificate                 /* my certificate path */;
        ssl_certificate_key             /* my certificate path */;

        location / {
                proxy_pass                      http://192.168.0.1:4000;
                add_header                      Alt-Svc 'h3=":443"; ma=86400';
        }
}

nginx에 변경사항을 반영하고 결과를 확인 해 보겠습니다.

/usr/local/nginx/nginx -s reload

네트워크 탭 에서 프로토콜이 h3으로 바뀐것을 볼 수 있습니다.

보안 탭에서는 인증서에 대한 연결 정보를 확인 할 수 있습니다.

0개의 댓글