events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; # 로그 설정 access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # 업로드 크기 제한 client_max_body_size 10M; server { listen 80; server_name localhost; # 클라우드플레어 IP 대역 허용 allow 173.245.48.0/20; allow 103.21.244.0/22; allow 103.22.200.0/22; allow 103.31.4.0/22; allow 141.101.64.0/18; allow 108.162.192.0/18; allow 190.93.240.0/20; allow 188.114.96.0/20; allow 197.234.240.0/22; allow 198.41.128.0/17; allow 162.158.0.0/15; allow 104.16.0.0/13; allow 104.24.0.0/14; allow 172.64.0.0/13; allow 131.0.72.0/22; # 경기도 IP 대역 허용 (주요 ISP) allow 211.0.0.0/8; # KT allow 175.0.0.0/8; # KT allow 121.0.0.0/8; # SK브로드밴드 allow 1.0.0.0/8; # SK브로드밴드 allow 112.0.0.0/8; # LG유플러스 allow 106.0.0.0/8; # LG유플러스 allow 127.0.0.1; # 로컬호스트 allow 192.168.0.0/16; # 내부 네트워크 deny all; # 나머지 모든 IP 차단 # HTML 파일 캐시 제어 location ~* \.(html)$ { root /usr/share/nginx/html; expires -1; add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; add_header Pragma "no-cache"; add_header Last-Modified $date_gmt; add_header ETag ""; if_modified_since off; } # 프론트엔드 파일 서빙 location / { root /usr/share/nginx/html; index index.html; try_files $uri $uri/ /index.html; } # JS/CSS 파일 캐시 제어 (모바일 강화) location ~* \.(js|css)$ { root /usr/share/nginx/html; expires -1; add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; add_header Pragma "no-cache"; add_header Last-Modified $date_gmt; add_header ETag ""; if_modified_since off; # 모바일 캐시 방지 추가 헤더 add_header Vary "User-Agent"; add_header X-Accel-Expires "0"; } # API 프록시 (백엔드에서 CORS 처리) location /api/ { proxy_pass http://backend:8000/api/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_cache_bypass $http_upgrade; } # 업로드된 파일 서빙 location /uploads/ { alias /usr/share/nginx/html/uploads/; expires 1y; add_header Cache-Control "public, immutable"; } } }