nginx

원본 압축관련 최종 nginx proxy설정

꺼비72 2024. 4. 29. 10:20
반응형
server {
 server_name relay;
 access_log /var/log/nginx/relay.log  my_log;
 listen 80;
 proxy_cache my_zone;

 if ($http_accept_encoding = "") { set $encoding "gzip"; break; }
 if ($http_accept_encoding ~ br) { set $encoding "br, gzip"; break; }
 if ($http_accept_encoding ~ gzip) { set $encoding "gzip"; break; }

 add_header X-CACHE-STATUS "$upstream_cache_status";
 proxy_http_version 1.1;
 proxy_set_header Connection "";
 proxy_buffering on;
 proxy_ignore_headers Vary ;
 proxy_cache_key $host$uri$is_args$args$encoding;
 gunzip on;
 proxy_set_header Accept-Encoding "$encoding";

 # gzip config
    gzip on;
    gzip_types text/plain text/css text/html text/javascript;
    gzip_min_length 100;
    gzip_comp_level   4;

 # brotli config
    brotli on;
    brotli_comp_level  6;
    brotli_types text/plain text/css text/html text/javascript;
    brotli_min_length 100;

 location / {
   proxy_pass http://org;
 }
}

'nginx' 카테고리의 다른 글

ngx_http_gzip_static_module  (0) 2024.05.06
chunked_transfer_encoding  (0) 2024.04.29
gzip 최대 압축지원  (0) 2024.04.29
압축을 지원하지 않는 원본일 경우 Proxy에서 압축  (0) 2024.04.29
gunzip을 사용해 Cache key절약  (0) 2024.04.29