From 2211eaa1e2e11d8c5ce2c9deeb0c695c80b9d209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Wed, 7 Oct 2026 09:18:42 +0300 Subject: [PATCH] feat(infra): add nginx load balancer config and compose mod --- compose.yaml | 3 ++- infra/nginx.conf | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 infra/nginx.conf diff --git a/compose.yaml b/compose.yaml index 7ff31ce..d6cf8c6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,4 +1,4 @@ -name: mtusi-messenger-lab2 +name: mtusi-messenger-lab3 services: postgres: @@ -58,6 +58,7 @@ services: CACHE_URL_FILE: /run/secrets/cache_url SESSION_STORE: "redis" SESSION_TTL_SECONDS: "3600" + IDEMPOTENCY_TTL_SECONDS: "86400" secrets: - database_url - cache_url diff --git a/infra/nginx.conf b/infra/nginx.conf new file mode 100644 index 0000000..6ec1b49 --- /dev/null +++ b/infra/nginx.conf @@ -0,0 +1,42 @@ +worker_processes auto; + +events { + worker_connections 512; +} + +http { + access_log /dev/stdout; + error_log /dev/stderr warn; + + resolver 127.0.0.11 valid=10s ipv6=off; + + upstream backend { + zone backend 64k; + + server api:8080 resolve max_fails=2 fail_timeout=5s; + + keepalive 32; + } + + server { + listen 8080; + server_tokens off; + + location / { + proxy_pass http://backend; + proxy_http_version 1.1; + proxy_set_header Connection ""; + 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; + + proxy_connect_timeout 2s; + proxy_send_timeout 30s; + proxy_read_timeout 30s; + + proxy_next_upstream error timeout; + proxy_next_upstream_tries 2; + } + } +} \ No newline at end of file