server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # 폴더 주소로 넘길 때 포트가 빠지지 않게 상대 주소로 보낸다 absolute_redirect off; gzip on; gzip_types text/css application/javascript image/svg+xml application/json; # 해시가 붙은 빌드 파일은 오래 캐시 location /assets/ { add_header Cache-Control "public, max-age=31536000, immutable"; try_files $uri =404; } location /icons/ { add_header Cache-Control "public, max-age=604800"; try_files $uri =404; } # SPA: /indices, /sky 같은 주소로 새로고침해도 index.html을 돌려준다 location / { add_header Cache-Control "no-cache"; try_files $uri $uri/ /index.html; } }