From 93ce8bcf7297d9ecbdd1e8a3a15f3d856b22ca47 Mon Sep 17 00:00:00 2001 From: Roman Mutel Date: Tue, 14 May 2024 02:11:48 +0300 Subject: [PATCH] added nginx as a reverse proxy server --- compose.yaml | 25 +++++++++++++++++-------- nginx.conf | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 nginx.conf diff --git a/compose.yaml b/compose.yaml index 59e032c..173adb1 100644 --- a/compose.yaml +++ b/compose.yaml @@ -34,8 +34,8 @@ services: depends_on: consul: condition: service_healthy - ports: - - "8000-8002:8080" + # ports: + # - "8000-8002:8080" auth-db: image: postgres:latest environment: @@ -61,8 +61,8 @@ services: condition: service_healthy environment: CONSUL_ADDR: consul:8500 - ports: - - "8003:8080" + # ports: + # - "8003:8080" packs-db: build: context: src/coffee-packs @@ -98,8 +98,8 @@ services: condition: service_healthy environment: CONSUL_ADDR: consul:8500 - ports: - - "8004:8080" + # ports: + # - "8004:8080" shops-db: build: context: src/coffee-shops @@ -130,8 +130,8 @@ services: condition: service_healthy networks: - kavuny-net - ports: - - "8005:8080" + # ports: + # - "8005:8080" environment: CONSUL_ADDR: consul:8500 check-ins-db-1: @@ -199,6 +199,15 @@ services: depends_on: - zookeeper + nginx: + image: nginx:latest + ports: + - "8080:8080" + volumes: + - ./nginx.conf:/etc/nginx/conf.d/default.conf + networks: + - kavuny-net + networks: kavuny-net: driver: bridge diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..0c3d166 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,35 @@ +server { + listen 8080; + listen [::]:8080; + server_name localhost; + + location /packs { + proxy_pass http://coffee-packs:8080/packs; + } + + location /coffee-shops { + proxy_pass http://coffee-shops:8080/coffee-shops; + } + + location /check-ins { + proxy_pass http://check-ins:8080/check-ins; + } + + location ~ ^/auth/(.*)$ { + rewrite ^/auth/(.*)$ /$1 break; + proxy_pass http://auth:8080; + } + + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + +} +