events { worker_connections 1024; } http { upstream backend { # ИЗМЕНЕНО: Уменьшены max_fails и fail_timeout для быстрого failover server api:8080 max_fails=2 fail_timeout=5s; } server { listen 8080; location / { proxy_pass http://backend; 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_connect_timeout 3s; proxy_read_timeout 10s; proxy_next_upstream error timeout http_502 http_503 http_504; proxy_next_upstream_tries 2; proxy_next_upstream_timeout 5s; } } }