docker-compose.yml
version: '3'
services:
backend:
build:
context: .
dockerfile: ./backend/Dockerfile
expose:
- 5000
ports:
- "5000:5000"
links:
- mongo_db:mongo_db
depends_on:
- mongo_db
#restart: always
volumes:
- ./backend/flask_app:/usr/src/app
command: gunicorn -w 1 -b 0.0.0.0:5000 wsgi:app
frontend:
build:
context: .
dockerfile: ./frontend/Dockerfile
expose:
- 3000
ports:
- "3000:3000"
volumes:
- ./frontend:/app
- /app/node_modules
stdin_open: true
tty: true
#restart: always
mongo_db:
image: mongo:latest
restart: unless-stopped
environment: # ํ๊ฒฝ๋ณ์๋ฅผ ์ ์ํฉ๋๋ค.
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: vitaminc
volumes:
- ./mongo/db:/data/db
ports:
- "27017:27017"
nginx:
image: nginx:latest
ports:
- "8080:8080"
- "8081:8081"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
depends_on:
- frontend
- backend
restart: "on-failure"
nginx/nginx.conf
nginx์ reverse proxy -> 8080 (ํ๋ก ํธ), 8081(๋ฐฑ)
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$request_uri" "$uri"'
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
upstream docker-front{
server frontend:3000;
}
upstream docker-back {
server backend:5000;
}
server {
listen 8080;
server_name localhost;
location / {
proxy_pass http://docker-front;
proxy_redirect off;
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-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 8081;
server_name localhost;
location / {
proxy_pass http://docker-back;
proxy_redirect off;
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-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
aws ec2 ์ธ์คํด์ค๋ฅผ ์ด์ฉํด ์๋ฒ๋ฅผ ๊ตฌ์ถํ์๋ค.
pem ๋ณด์ ํ์ผ์ ๋ํ ์ ์ฅ์ด ํ์์ด๋ค. pemํ์ผ์ ์ด์ฉํด ์ฐ๋ถํฌ ssh ์๋ฒ๋ฅผ ๊ตฌ์ถํ๋ค.
'2021 silicon valley online internship' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Nginx Reverse Proxy (0) | 2022.03.17 |
---|---|
์ธํด์ญ ์๋ฃ์ฆ ๐ (0) | 2022.03.15 |
AWS EC2 ์น์๋ฒ ๊ตฌ์ถํ๊ธฐ (0) | 2021.07.02 |