Files
mtusi2026lab3/infra/nginx/default.conf
T

37 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LB без sticky session: каждый запрос независимо уходит на любую живую реплику.
# Docker DNS отдаёт имя `api` → IP всех работающих реплик (в случайном порядке);
# resolver с valid=1s заставляет nginx обновлять список backend каждую секунду,
# поэтому остановленная реплика исчезает из ротации максимум за ~1-2 с.
resolver 127.0.0.11 valid=1s ipv6=off;
server {
listen 80;
server_name _;
# Проверка самого LB (healthcheck контейнера).
location = /lb-health {
access_log off;
default_type text/plain;
return 200 "ok\n";
}
location / {
set $api_upstream http://api:8080;
proxy_pass $api_upstream;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
# Отказ реплики: быстрый connect-timeout и повтор на другом адресе.
# Повторяются только ошибки соединения/таймаут/502/503/504; POST после отправки тела
# автоматически НЕ повторяется (без non_idempotent) — безопасный повтор делает клиент
# с тем же Idempotency-Key.
proxy_connect_timeout 1s;
proxy_send_timeout 10s;
proxy_read_timeout 10s;
proxy_next_upstream error timeout http_502 http_503 http_504;
proxy_next_upstream_tries 3;
proxy_next_upstream_timeout 5s;
}
}