diff --git a/frontend/Caddyfile b/frontend/Caddyfile new file mode 100644 index 0000000..e6fc804 --- /dev/null +++ b/frontend/Caddyfile @@ -0,0 +1,12 @@ +:80 { + root * /srv + file_server + encode gzip + + # 정적 에셋 캐싱 (해시된 파일명) + @immutable path /_app/immutable/* + header @immutable Cache-Control "public, max-age=31536000, immutable" + + # SPA fallback + try_files {path} /index.html +} diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 3a33433..e4646b1 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -12,12 +12,12 @@ COPY . . RUN npm run build # ── 실행 스테이지 ────────────────────────────────────────── -FROM nginx:alpine +FROM caddy:alpine -# nginx 설정 복사 -COPY nginx.conf /etc/nginx/conf.d/default.conf +# Caddyfile 복사 +COPY Caddyfile /etc/caddy/Caddyfile # 빌드 결과물 복사 -COPY --from=builder /app/build /usr/share/nginx/html +COPY --from=builder /app/build /srv EXPOSE 80 diff --git a/frontend/nginx.conf b/frontend/nginx.conf deleted file mode 100644 index c7c2011..0000000 --- a/frontend/nginx.conf +++ /dev/null @@ -1,42 +0,0 @@ -server { - listen 80; - server_name _; - root /usr/share/nginx/html; - index index.html; - - # SPA fallback: 파일이 없으면 index.html로 - location / { - try_files $uri $uri/ /index.html; - } - - # 정적 에셋 캐싱 (해시된 파일명) - location /_app/immutable/ { - expires 1y; - add_header Cache-Control "public, immutable"; - } - - # API/WS는 백엔드로 프록시 (docker-compose에서 설정) - location /api/ { - proxy_pass http://backend:8080; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - } - - location /ws { - proxy_pass http://backend:8080; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - } - - location /login { - proxy_pass http://backend:8080; - proxy_set_header Host $host; - } - - location /logout { - proxy_pass http://backend:8080; - proxy_set_header Host $host; - } -}