Skip to content

Commit

Permalink
feat: nginx 및 https 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
chan-byeong committed Nov 29, 2024
1 parent fe6a38d commit 536243a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/frontend-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ jobs:
docker run -d \
--name you-quiz-fe \
--env-file packages/client/.env \
-p 80:4173 \
-v /etc/letsencrypt/live/www.you-quiz.site/fullchain.pem:/etc/nginx/ssl/fullchain.pem \
-v /etc/letsencrypt/live/www.you-quiz.site/privkey.pem:/etc/nginx/ssl/privkey.pem \
-p 80:80 \
-p 443:443 \
you-quiz-fe:${{ github.run_number }}
28 changes: 8 additions & 20 deletions Dockerfile.fe
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,16 @@ RUN yarn install
WORKDIR /app/packages/client
RUN yarn build

# 실행 스테이지
FROM node:22.9.0-alpine AS runner
#Nginx 스테이지
FROM nginx:alpine AS nginx

WORKDIR /app

# 필요한 파일 복사 순서 변경 및 종속성 설치 추가
COPY --from=builder /app/package.json ./
COPY --from=builder /app/tsconfig.json ./
COPY --from=builder /app/yarn.lock ./
COPY --from=builder /app/.yarnrc.yml ./
COPY --from=builder /app/.yarn ./.yarn
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/packages/client/dist /usr/share/nginx/html

# 종속성 설치 추가
RUN yarn install
COPY nginx.conf /etc/nginx/conf.d/default.conf

# 환경 변수 설정
ENV NODE_ENV production
ENV PORT 4173
RUN mkdir -p /etc/nginx/ssl

# 포트 설정
EXPOSE 4173
EXPOSE 80
EXPOSE 443

# 실행 명령어
CMD ["yarn", "workspace", "client", "preview", "--host", "0.0.0.0"]
CMD ["nginx", "-g", "daemon off;"]
23 changes: 23 additions & 0 deletions packages/client/src/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;
server_name www.you-quiz.site;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name www.you-quiz.site;

ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers off;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;try_files $uri $uri/ /index.html;
}
}

0 comments on commit 536243a

Please sign in to comment.