forked from mtusi2026/mtusi2026lab7
3grade_1change
This commit is contained in:
+5
-5
@@ -4,17 +4,18 @@ 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;
|
||||
listen 8443 ssl;
|
||||
|
||||
# Пути к сертификатам (мы сгенерируем их в шаге 2)
|
||||
ssl_certificate /etc/nginx/certs/nginx.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/nginx.key;
|
||||
|
||||
# Проверка, что LB жив (без проксирования в API)
|
||||
location = /lb-health {
|
||||
access_log off;
|
||||
return 200 'ok';
|
||||
@@ -29,7 +30,6 @@ http {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user