Module ngx_http_v2_module

Module ngx_http_v2_module The ngx_http_v2_module module (1.9.5) provides support for HTTP/2. This module is not built by default, it should be enabled with the --with-http_v2_module configuration parameter. Known Issues Before version 1.9.14, buffering of

nginx.org

 

  • ngx_http_v2_module 모듈(1.9.5)은 HTTP/2를 지원
  • ngx_http_v2_module 모듈은 기본적으로 빌드되지 않으며, --with-http_v2_module 구성 매개변수를 사용하여 활성화

 

  • TLS를 통해 HTTP/2 연결을 수락하려면 OpenSSL 버전 1.0.2부터 제공되는 “ALPN(Application-Layer Protocol Negotiation)” TLS 확장 지원이 필요
  • ssl_prefer_server_ciphers 지시어가 on 값으로 설정된 경우 암호는 RFC 9113의 부록 A 블랙리스트(black list)를 준수하고 클라이언트에서 지원하도록 구성
  • RFC 9113의 부록 A : https://datatracker.ietf.org/doc/html/rfc9113#appendix-A

 

  • Nginx 1.9.14 버전 이전에는 proxy_request_buffering, fastcgi_request_buffering, uwsgi_request_buffering 및 scgi_request_buffering 지시어 값에 관계없이 client request body 버퍼링(Buffering)을 비활성화할 수 없음
  • Nginx 1.19.1 이전에는 HTTP/2 연결(connections) 종료를 제어하는 데, lingering_close 메커니즘 사용 X

 

ngx_http_v2_module 구성 예

server {
    listen 443 ssl;

    http2 on;

    ssl_certificate server.crt;
    ssl_certificate_key server.key;
}

 

 

http2 지시자

  • HTTP/2 프로토콜을 활성화
     
  • 문맥: http, server
  • 사용 문법
    # 문법
    http2 on | off;
  • 기본 사용 예시
    http2 off;

 

 

http2_body_preread_size 지시자

  • 요청(request)을 처리 시작하기 전에 요청 본문(request body)이 저장될 수 있는 각 요청(request)당 버퍼(buffer)의 크기를 설정
     
  • 문맥: http, server
  • 사용 문법
    # 문법
    http2_body_preread_size size;
  • 기본 사용 예시
    http2_body_preread_size 64k;

 

 

http2_chunk_size 지시자

  • 응답 본문(response body)이 슬라이스(slice)되는 청크(chunks)의 최대 크기를 설정 
  • 슬라이스(slice)되는 청크(chunks) 값이 너무 낮으면 오버헤드가 증가 
  • 슬라이스(slice)되는 청크(chunks) 값이 너무 높으면 HOL 블로킹으로 인해 우선 순위가 손상
     
  • 문맥: http, server, location
  • 사용 문법
    # 문법
    http2_chunk_size size;
  • 기본 사용 예시
    http2_chunk_size 8k;

 

 

http2_max_concurrent_streams 지시자

  • 연결(connection)에서 최대 동시 HTTP/2 스트림(concurrent HTTP/2 streams) 수를 설정
     
  • 문맥: http, server
  • 사용 문법
    # 문법
    http2_max_concurrent_streams number;
  • 기본 사용 예시
    http2_max_concurrent_streams 128;

 

 

http2_recv_buffer_size 지시자

  • 작업자(worker)당 입력 버퍼(input buffer)의 크기를 설정
     
  • 문맥: http
  • 사용 문법
    # 문법
    http2_recv_buffer_size size;
  • 기본 사용 예시
    http2_recv_buffer_size 256k;

 

 

ngx_http_v2_module 모듈의 내장 변수 → $http2

  • negotiated protocol identifier(협상된 프로토콜 식별자)
    1. TLS를 통한 HTTP/2의 경우 “h2”
    2. 투명 텍스트 TCP(cleartext TCP)를 통한 HTTP/2의 경우 “h2c”
    3. 그렇지 않으면 빈 문자열

 

 

http2_max_concurrent_pushes 지시자

  • http2_max_concurrent_pushes 지시어는 버전 1.25.1부터 사용 X
  • 연결(connection)에서 동시 푸시 요청(concurrent push requests )의 최대 수(maximum number)를 제한
     
  • 문맥: http, server
  • 사용 문법
    # 문법
    http2_max_concurrent_pushes number;
  • 기본 사용 예시
    http2_max_concurrent_pushes 10;

 

 

http2_push 지시자

  • http2_push 지시어는 버전 1.25.1부터 사용 X
  • original 요청에 대한 응답과 함께 지정된 URI로 요청을 선제적(pre-emptively)으로 전송(푸시)
  • 예) 절대 경로(absolute path)를 가진 상대 URI(relative URI)만 처리 : http2_push /static/css/main.css;
     
  • URI 값에는 변수가 포함 가능
  • 동일한 설정 수준에서 여러 개의 http2_push 지시문을 지정 가능 
  • http2_push 지시어의 off 매개변수는 이전 configuration에서 상속된 http2_push 지시어의 효과를 취소함
     
  • 문맥: http, server, location
  • 사용 문법
    # 문법
    http2_push uri | off;
  • 기본 사용 예시
    http2_push off;

 

 

http2_push_preload 지시자

  • http2_push_preload 지시어는 버전 1.25.1부터 사용 X
  • Link 응답 헤더 필드(response header field)에 지정된 프리로드 링크(preload links)를 푸시 요청(push requests)으로 자동 변환
     
  • 문맥: http, server, location
  • 사용 문법
    # 문법
    http2_push_preload on | off;
  • 기본 사용 예시
    http2_push_preload off;

 

 

http2_idle_timeout 지시자

  • http2_idle_timeout 지시어는 버전 1.19.7부터 사용 X → http2_idle_timeout 대신 keepalive_timeout를 사용
  • 연결(connection)이 닫히는 비활성 시간 제한(timeout of inactivity)을 설정
     
  • 문맥: http, server
  • 사용 문법
    # 문법
    http2_idle_timeout time;
  • 기본 사용 예시
    http2_idle_timeout 3m;

 

 

http2_max_field_size 지시자

  • http2_max_field_size 지시어는 버전 1.19.7부터 사용 X → http2_max_field_size 대신 large_client_header_buffers 사용
  • HPACK 압축 요청 헤더 필드(HPACK-compressed request header)의 최대 크기를 제한 → 최대 크기 제한은 이름과 값 모두에 동일하게 적용 
  • 허프만 인코딩(Huffman encoding)이 적용되면 압축 해제된 이름 및 값 문자열의 실제 크기가 더 커질 수 있음
  • 대부분의 요청은 http2_max_field_size 기본 제한 크기로 충분
  • HPACK 압축 : https://datatracker.ietf.org/doc/html/rfc7541
     
  • 문맥: http, server
  • 사용 문법
    # 문법
    http2_max_field_size size;
  • 기본 사용 예시
    http2_max_field_size 4k;

 

 

http2_max_header_size 지시자

  • http2_max_header_size 지시어는 1.19.7부터 사용 X → http2_max_header_size 대신 large_client_header_buffers 사용
  • HPACK 압축 해제(HPACK decompression) 후 전체 요청 헤더 목록(entire request header list)의 최대 크기를 제한 
  • 대부분의 요청(requests)에서는 기본 제한으로 충분
     
  • 문맥: http, server
  • 사용 문법
    # 문법
    http2_max_header_size size;
  • 기본 사용 예시
    http2_max_header_size 16k;

 

 

http2_max_requests 지시자

  • http2_max_requests 지시어는 버전 1.19.7부터 사용 X → http2_max_requests 대신 keepalive_requests 사용
  • 하나의 HTTP/2 연결(HTTP/2 connection)을 통해 처리할 수 있는 최대 요청 수(push requests 포함)를 설정하며, 그 이후 다음 클라이언트 요청(next client request)이 있을 때 연결이 닫히고 새 연결을 진행
  • 주기적으로 연결을 닫는 것은 연결별 메모리 할당(per-connection memory allocations)을 확보하기 위해 필요 
  • 최대 요청 수를 너무 많이 사용하면 메모리를 과도하게 사용할 수 있으므로 권장 X
     
  • 문맥: http, server
  • 사용 문법
    # 문법
    http2_max_requests number;
  • 기본 사용 예시
    http2_max_requests 1000;

 

 

http2_recv_timeout  지시자

  • http2_recv_timeout 지시어는 1.19.7부터 사용 X → http2_recv_timeout  대신 client_header_timeout를 사용
  • 클라이언트로부터 추가로 전달될 데이터를 기대하는 시간 제한(timeout) 설정한 후 연결을 닫음.
     
  • 문맥: http, server
  • 사용 문법 
  • # 문법 http2_recv_timeout time;
  • 기본 사용 예시
    http2_recv_timeout 30s;

 

 

'Nginx > Nginx 모듈 학습' 카테고리의 다른 글

ngx_http_auth_basic_module 모듈  (1) 2024.12.15
ngx_http_autoindex_module 모듈  (0) 2024.12.15
ngx_http_dav_module 모듈  (1) 2024.12.11
ngx_http_hls_module 모듈  (0) 2023.09.24
ngx_http_mp4_module 모듈  (0) 2023.09.24

+ Recent posts