lab3_and_3grade

This commit is contained in:
caramelteawithmint
2026-11-13 18:01:54 +03:00
parent ec540a1a72
commit 09e26c3c5a
28 changed files with 1494 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
worker_processes auto;
events { worker_connections 1024; }
http {
upstream api_backend {
# least_conn лучше распределяет запросы, чем round-robin,
# особенно когда одна реплика чуть медленнее.
least_conn;
server api1:8080 max_fails=1 fail_timeout=2s;
server api2:8080 max_fails=1 fail_timeout=2s;
}
server {
listen 8080;
# Проверка, что LB жив (без проксирования в API)
location = /lb-health {
access_log off;
return 200 'ok';
add_header Content-Type text/plain;
}
location / {
proxy_pass http://api_backend;
proxy_http_version 1.1;
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_next_upstream error timeout http_502 http_503 http_504;
proxy_connect_timeout 2s;
proxy_read_timeout 10s;
}
}
}