2025-06-18 14:31:20 +09:00

97 lines
2.9 KiB
Nginx Configuration File

server {
listen 18080;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
# 에러 페이지 설정
error_page 404 /index.html;
error_page 500 502 503 504 /50x.html;
# 로깅 설정 (디버깅용)
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
# ⚠️ 중요: runtime-env.js 파일 특별 처리
location = /runtime-env.js {
try_files $uri $uri/ =404;
expires -1;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Content-Type "application/javascript";
# CORS 헤더 추가
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type";
}
# SPA 라우팅 처리 (Vue Router)
location / {
try_files $uri $uri/ /index.html;
# HTML 파일은 캐시하지 않음
location ~* \.html$ {
expires -1;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
}
}
# 정적 자산 캐시 최적화 (runtime-env.js 제외)
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
# runtime-env.js는 위에서 별도 처리되므로 제외
if ($uri = "/runtime-env.js") {
break;
}
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_proxied any;
gzip_comp_level 6;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/xml+rss
application/json
application/xml
image/svg+xml;
# 보안 헤더
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' http://smarketing.20.249.184.228.nip.io https://smarketing.20.249.184.228.nip.io" always;
# 헬스체크 엔드포인트
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# 파비콘 캐시
location /favicon.ico {
expires 1M;
access_log off;
log_not_found off;
}
# 숨겨진 파일 접근 차단
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}