Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
48 lines
1.6 KiB
Nginx Configuration File
48 lines
1.6 KiB
Nginx Configuration File
upstream api_backend {
|
|
# Балансировка между несколькими API-репликами.
|
|
server api-1:8080 max_fails=3 fail_timeout=10s;
|
|
server api-2:8080 max_fails=3 fail_timeout=10s;
|
|
}
|
|
|
|
server {
|
|
listen 8080;
|
|
server_name localhost;
|
|
|
|
# Таймауты для предотвращения зависаний.
|
|
proxy_connect_timeout 5s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
|
|
# Передача заголовков клиента в backend.
|
|
proxy_set_header Host $http_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;
|
|
|
|
# Основной location для API.
|
|
location / {
|
|
proxy_pass http://api_backend;
|
|
proxy_set_header Host $http_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;
|
|
}
|
|
|
|
# Health check endpoint для Nginx.
|
|
location /health/live {
|
|
proxy_pass http://api_backend/health/live;
|
|
proxy_set_header Host $http_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;
|
|
}
|
|
|
|
location /health/ready {
|
|
proxy_pass http://api_backend/health/ready;
|
|
proxy_set_header Host $http_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;
|
|
}
|
|
}
|