Skip to content

Commit

Permalink
chore : backend nginx 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellol77 committed Aug 16, 2024
1 parent 124f5b2 commit ee27fdd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
23 changes: 14 additions & 9 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
FROM node:lts-alpine
WORKDIR /usr/app
# 베이스 이미지 설정
FROM node:14

# Copy the package.json and package-lock.json files
COPY package*.json ./
# 작업 디렉토리 생성
WORKDIR /app

# Install any needed packages
# 의존성 파일을 복사하고 설치
COPY package*.json ./
RUN npm install

# Copy the rest of the application code
# 애플리케이션 소스 복사
COPY . .

# Expose the port the app runs on
# Nginx 설치 및 설정 복사
RUN apt-get update && apt-get install -y nginx
COPY nginx.conf /etc/nginx/conf.d/

# 포트 설정
EXPOSE 3000

# Run the app
CMD [ "node", "src/index.js" ]
# Nginx와 Node.js 서버를 모두 실행
CMD ["sh", "-c", "service nginx start && node src/index.js"]
15 changes: 15 additions & 0 deletions backend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server {
listen 80;
server_name worry-is-bubble.com;

location /api {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
7 changes: 0 additions & 7 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@ server {
try_files $uri /index.html;
}

location /api/ {
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 ee27fdd

Please sign in to comment.