38 lines
1.2 KiB
Nginx Configuration File
38 lines
1.2 KiB
Nginx Configuration File
worker_processes auto;
|
|
events { worker_connections 1024; }
|
|
|
|
http {
|
|
# access_log / error_log по умолчанию в stdout/stderr образа nginx.
|
|
|
|
upstream api_backend {
|
|
# Docker DNS отдаёт все IP реплик сервиса api.
|
|
server api:8080 max_fails=2 fail_timeout=5s;
|
|
keepalive 32;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
|
|
# Короткие таймауты, чтобы мёртвый backend быстро исключался.
|
|
proxy_connect_timeout 2s;
|
|
proxy_send_timeout 10s;
|
|
proxy_read_timeout 10s;
|
|
|
|
location / {
|
|
proxy_pass http://api_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_next_upstream error timeout http_502 http_503 http_504;
|
|
proxy_next_upstream_tries 2;
|
|
}
|
|
|
|
# readiness LB напрямую проверяет свой upstream через api (docker healthcheck).
|
|
location = /lb/health {
|
|
return 200 "ok\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
}
|
|
} |