Brotli

Brotli

NGINX Plus와 함께 Brotli 모듈을 사용하는 방법에 대해 알아봅니다.

목차

1. 개요
2. 전제 조건
3. 설치
4. NGINX Plus 구성
5. 추가 정보

1. 개요

Brotli는 LZ77 알고리즘, Huffman 코딩 및 second‑order context 모델링의 변형을 사용하는 무손실 데이터 압축 알고리즘입니다. 압축 비율은 현재 사용 가능한 가장 좋은 범용 압축 방법과 비슷합니다. 속도는 DEFLATE와 비슷하지만 더 조밀하게 압축됩니다.

ngx_brotli 모듈은 NGINX Plus에서 Brotli 압축을 활성화하며 두 개의 모듈로 구성됩니다.

  • ngx_brotli filter module – 즉석에서 응답을 압축하기 위해
  • ngx_brotli static module – 미리 압축된 파일을 제공하기 위해

2. 전제 조건

1. 기술 사양 페이지를 확인하여 모듈이 운영 체제에서 지원되는지 확인합니다.

2. 필요한 경우 epel-release 종속성을 설치합니다.

  • Amazon Linux 2 LTS의 경우:
$ sudo amazon-linux-extras install epel -y
  • CentOS, Oracle Linux, and RHEL의 경우:
$ sudo yum install epel-release -y

3. 설치

nginx-plus-module-brotli 모듈 설치

  • Amazon Linux 2 LTS, CentOS, Oracle Linux 및 RHEL의 경우:
$ yum install nginx-plus-module-brotli
  • Debian 및 Ubuntu의 경우:
$ apt-get install nginx-plus-module-brotli
  • SLES 15의 경우:
$ zypper install nginx-plus-module-brotli

4. NGINX Plus 구성

설치 후 NGINX Plus 구성 파일 nginx.conf에서 Brotli 모듈을 활성화하고 구성해야 합니다.

1. 최상위(“main”) context에 지정된 load_module 지시문을 사용하여 Brotli 모듈의 동적 로딩(dynamic loading)를 활성화합니다.

load_module modules/ngx_http_brotli_filter_module.so; # for compressing responses on-the-fly
load_module modules/ngx_http_brotli_static_module.so; # for serving pre-compressed files

http {
    #...
}

2. Brotli 압축을 사용하도록 설정하고 ngx_brotli 모듈에 필요한 추가 구성을 수행합니다. Brotli 압축은 http, 서버 또는 location 레벨에서 구성할 수 있습니다.

http {

    server {
        brotli on;
        #...
    }
}

3. 구성을 테스트하고 NGINX Plus를 다시 로드하여 모듈을 활성화합니다.

$ nginx -t && nginx -s reload

5. 추가 정보