Skip to content

Commit

Permalink
fix: nginx 설정 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seokkkkkk committed Jul 17, 2024
1 parent f16641a commit 95fb3cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
14 changes: 10 additions & 4 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Stage 1: Build
FROM node:lts AS build

WORKDIR /app
Expand All @@ -10,18 +11,23 @@ COPY . .

RUN npm run build

# Stage 2: Serve with Nginx
FROM nginx:stable-alpine

# 기본 nginx 설정 제거 및 설정 복사
# Remove default Nginx configuration and copy custom config
RUN rm -rf /etc/nginx/conf.d
COPY conf /etc/nginx

# 빌드된 파일을 nginx에 복사
# Copy SSL certificates
COPY path/to/your/ssl/certificates/nginx.crt /etc/nginx/ssl/nginx.crt
COPY path/to/your/ssl/certificates/nginx.key /etc/nginx/ssl/nginx.key

# Copy built files to Nginx
COPY --from=build /app/build /usr/share/nginx/html

# HTTP(80) 및 HTTPS(443) 포트 오픈
# Expose HTTP and HTTPS ports
EXPOSE 80
EXPOSE 443

# nginx 실행
# Run Nginx
CMD ["nginx", "-g", "daemon off;"]
23 changes: 19 additions & 4 deletions conf/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@ server {
listen 80;
server_name syluv.store www.syluv.store;

# HTTP 요청을 HTTPS로 리디렉션
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
return 301 https://$host$request_uri;
}
}
}

server {
listen 443 ssl;
server_name syluv.store www.syluv.store;

ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;

location / {
proxy_pass http://localhost:3000;
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;
}
}

0 comments on commit 95fb3cf

Please sign in to comment.