From 8d207243f749bb5567621be19b171e1903056a36 Mon Sep 17 00:00:00 2001 From: Stepasha419a Date: Fri, 13 Dec 2024 17:07:02 +0300 Subject: [PATCH] feature: nginx auth-service proxy --- .env.dev | 9 +++++---- docker-compose.yaml | 2 ++ nginx/nginx-dev.conf | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.env.dev b/.env.dev index a1011dbf..e992d25f 100644 --- a/.env.dev +++ b/.env.dev @@ -1,9 +1,10 @@ -VITE_USER_SERVICE_URL=http://localhost:5000 -VITE_CHAT_SERVICE_URL=http://localhost:5001 -VITE_FILE_SERVICE_URL=http://localhost:5002 -VITE_AUTH_SERVICE_URL=http://localhost:5003 +VITE_AUTH_SERVICE_URL=https://localhost:3000/auth-service-url VITE_MODE=dev PROXY_PORT=3000 CLIENT_URL=http://host.docker.internal:3001 + +PROXY_AUTH_SERVICE=/auth-service-url + +AUTH_SERVICE_URL=https://host.docker.internal:5003 \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index b1720905..edce8d70 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,4 +14,6 @@ services: /bin/sh -c "envsubst ' \$\{PROXY_PORT\} \$\{CLIENT_URL\} + \$\{PROXY_AUTH_SERVICE\} + \$\{AUTH_SERVICE_URL\} ' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && nginx -g 'daemon off;'" diff --git a/nginx/nginx-dev.conf b/nginx/nginx-dev.conf index 0d0b8581..3773bb36 100644 --- a/nginx/nginx-dev.conf +++ b/nginx/nginx-dev.conf @@ -20,5 +20,21 @@ http { add_header X-Proxy-Server $http_upgrade; } + + location ${PROXY_AUTH_SERVICE}/ { + proxy_pass ${AUTH_SERVICE_URL}/; + proxy_http_version 1.1; + + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Connection "upgrade"; + + proxy_ssl_certificate /etc/nginx/cert/dev/certificate.pem; + proxy_ssl_certificate_key /etc/nginx/cert/dev/private-key.pem; + + proxy_cookie_path ~*^/.* /; + + proxy_cache_bypass $http_upgrade; + } } } \ No newline at end of file