-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: NginX Docker 이미지 생성에 대한 Dockerfile 생성
- NginX 이미지 Dockerfile 생성 - NginX 설정 파일 생성 #5
- Loading branch information
1 parent
261dffc
commit 4924122
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM nginx:alpine | ||
WORKDIR /usr/share/nginx/html | ||
|
||
# Nginx 기본 설정 복사 | ||
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf | ||
|
||
EXPOSE 80 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM nginx:alpine | ||
WORKDIR /usr/share/nginx/html | ||
|
||
# Nginx 기본 설정 복사 | ||
COPY ./nginx/default.dev.conf /etc/nginx/conf.d/default.conf | ||
|
||
# 정적 파일을 호스트에서 복사 (개발 환경에서 핫 리로딩 사용 가능) | ||
EXPOSE 80 | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 백엔드 서버 정의 | ||
upstream backend { | ||
server backend:3000; # 백엔드 서버 (NestJS) | ||
} | ||
|
||
server { | ||
listen 80; | ||
|
||
# /api 경로로 들어오는 요청은 백엔드로 전달 | ||
location /api { | ||
proxy_pass http://backend; # 백엔드로 요청 전달 | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
|
||
# 정적 파일을 제공하는 기본 경로 설정 | ||
location / { | ||
root /usr/share/nginx/html; # React 빌드 결과물이 위치한 디렉터리 | ||
index index.html; # 기본 진입점 파일 | ||
try_files $uri /index.html; # SPA 라우팅 지원 | ||
} | ||
|
||
# 404 에러 페이지 설정 | ||
error_page 404 /404.html; | ||
location = /404.html { | ||
root /usr/share/nginx/html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 백엔드와 프론트엔드에 대한 업스트림 서버 정의 | ||
upstream backend { | ||
server backend:3000; # 백엔드 서버 (NestJS) | ||
} | ||
|
||
upstream frontend { | ||
server frontend:5173; # 프론트엔드 서버 (React) | ||
} | ||
|
||
server { | ||
listen 80; | ||
|
||
# /api 경로로 들어오는 요청은 백엔드로 전달 | ||
location /api { | ||
proxy_pass http://backend; # 백엔드로 요청 전달 | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
|
||
# 기본 경로는 프론트엔드로 전달 | ||
location / { | ||
proxy_pass http://frontend; | ||
} | ||
|
||
# /sockjs-node 경로 (React의 핫 리로딩 웹소켓 연결) | ||
location /sockjs-node { | ||
proxy_pass http://frontend; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
} | ||
} |