본문 바로가기
▶ Back-End/Server

Nginx Compression Gzip 설정

by 오늘도 코딩 2024. 6. 27.
728x90
반응형

Ngimx 간단한 설정 값 추가로 응답 리소스 사이즈를 줄일 수 있다.

*Tomcat 설정 시 미묘한 차이를 보여 Nginx로 교체

*자세한 설명 생략

 

 

▷ Nginx nginx.conf 설정

# Nginx worker 프로세스 수 설정
worker_processes 1;

# 에러 로그 파일 경로 및 로그 레벨 설정
#error_log  logs/error.log  notice;

# Nginx PID 파일 경로 설정
#pid  logs/nginx.pid;

events {
    # worker 프로세스 당 최대 연결 수 설정
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;

    # gzip 설정
    
    # gzip 설정 활성화
    gzip on;
    
    # gzip 압축 최소 길이 설정
    gzip_min_length 256;
    
    # gzip 압축 레벨 설정
    gzip_comp_level 6;
    
    # gzip 적용할 MIME 타입 설정(와일드 카드 없음)
    gzip_types
        text/plain
        text/css
        application/json
        application/javascript
        text/xml
        application/xml
        application/xml+rss
        text/javascript
        application/font-woff
        application/font-woff2
        application/vnd.ms-fontobject
        image/svg+xml;
    
    # gzip vary 헤더 활성화
    gzip_vary on;
    
    
    # TEST
    server {
        # 서버 포트 설정
        listen 8080;
        
        # 서버 이름 설정
        server_name TEST;
        
        # 파일 위치 설정
        location / {
            root C:/nginx-1.24.0/webapp/배포파일;
            try_files $uri $uri/ /index.html;
            index index.html index.htm;
        }
        
        # 에러 페이지 설정
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
}

 

 

▷ 결과

Tomcat에서 큰 파일 압축이 되지 않아 미묘한 차이를 보이던 부분

 

Tomcat 에서 미묘한 차이를 보이던 부분 해결

 

 

▷ 관련 글

 

Tomcat Compression Gzip 설정

Tomcat7부터  간단한 설정 값 추가로 응답 리소스 사이즈를 줄일 수 있다.*설정은 했지만 크게 감소하지 않음*자세한 설명 생략  ▷ Tomcat Server.xml 설정*Connector 부분에 추가 compression="on" compressableM

coding-today.tistory.com

 

 

728x90
728x90

댓글