server { listen 80; server_name localhost; # ---------------------------------------- # 보안 헤더 # ---------------------------------------- add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always; # ---------------------------------------- # 압축 (Gzip) # ---------------------------------------- gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml; # ---------------------------------------- # Nuxt SSG 라우팅 # - 프리렌더된 정적 페이지 우선 제공 # - 미생성 경로는 SPA 폴백(200.html)으로 클라이언트 라우팅 처리 # ---------------------------------------- location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /200.html; # 정적 자원 캐싱 (Nuxt 빌드 산출물은 해시 파일명이라 장기 캐싱 가능) location ~* \.(?:js|css|woff2?|ttf|svg|png|jpg|jpeg|gif|ico)$ { expires 30d; add_header Cache-Control "public, immutable"; } } # Nuxt 가 생성한 404 페이지 사용 error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # 숨김 파일 접근 차단 location ~ /\. { deny all; access_log off; log_not_found off; } }