From 47bb040eb86bf19a1d2cde57ab3981441dd3fff1 Mon Sep 17 00:00:00 2001 From: hayato5246 Date: Sun, 5 Apr 2026 20:57:59 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=84=EB=A1=A0=ED=8A=B8=EC=97=94=EB=93=9C?= =?UTF-8?q?=20=EC=84=9C=EB=B2=84=20=EA=B8=B0=EC=A1=B4=20Nginx=20=EA=B5=AC?= =?UTF-8?q?=EC=84=B1=EC=97=90=EC=84=9C=20Caddy=EB=A1=9C=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98:=20-=20Nginx=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=ED=8C=8C=EC=9D=BC(`nginx.conf`)=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20Caddy=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC(`Caddyfile`)=20=EC=B6=94=EA=B0=80.=20-=20Doc?= =?UTF-8?q?kerfile=EC=97=90=EC=84=9C=20Nginx=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EB=8C=80=EC=8B=A0=20Caddy=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95.=20-=20=EC=A0=95=EC=A0=81=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C(`/usr/share/nginx/html`=20=E2=86=92=20`/srv`?= =?UTF-8?q?)=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8.=20-?= =?UTF-8?q?=20=EC=A0=95=EC=A0=81=20=EC=97=90=EC=85=8B=20=EC=BA=90=EC=8B=B1?= =?UTF-8?q?=20=EB=B0=8F=20SPA=20fallback=20=EB=A1=9C=EC=A7=81=20Caddy?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=EC=9E=AC=EA=B5=AC=EC=84=B1.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/Caddyfile | 12 ++++++++++++ frontend/Dockerfile | 8 ++++---- frontend/nginx.conf | 42 ------------------------------------------ 3 files changed, 16 insertions(+), 46 deletions(-) create mode 100644 frontend/Caddyfile delete mode 100644 frontend/nginx.conf 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; - } -}