From 52af419254d0d9daf55f69d32f05c8e455339ded Mon Sep 17 00:00:00 2001 From: Chika Date: Tue, 29 Nov 2022 14:30:24 +0300 Subject: [PATCH] docker: add nginx server --- docker-compose.yml | 9 +++++++++ nginx.conf | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index 1be5f48..41d2791 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,8 @@ services: - APP_TITLE=${WEB_APP_TITLE} - APP_DESCRIPTION=${WEB_APP_DESCRIPTION} restart: always + networks: + - auth_network api: container_name: ${API_NAME} build: @@ -37,6 +39,13 @@ services: ALLOW_EMPTY_PASSWORD: 'yes' networks: - auth_network + server: + image: nginx + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + restart: always + networks: + - auth_network networks: auth_network: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..f640521 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,40 @@ + +worker_processes 4; + +events { + worker_connections 1024; +} + + +http { + upstream web { + server web:3000; + } + + upstream api { + server api:3001; + } + + server { + listen 80; + include /etc/nginx/mime.types; + + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + + location / { + proxy_pass http://web; + } + + location /api/ { + 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; + proxy_pass http://api/; + } + } +} \ No newline at end of file