Реализовать лабораторную 3 на оценку 5 (трек 1)
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# Public entry point for laboratory 3.
|
||||
#
|
||||
# Docker's embedded DNS (127.0.0.11) returns every healthy replica IP for the
|
||||
# compose service name "api". The shared upstream zone + "resolve" makes nginx
|
||||
# pick up scale-up/scale-down and replacement containers without a reload.
|
||||
# Passive checks remove a replica after one failed connection for 2 seconds;
|
||||
# proxy_next_upstream lets a safe retry reach another backend.
|
||||
|
||||
worker_processes auto;
|
||||
|
||||
events {
|
||||
worker_connections 4096;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
server_tokens off;
|
||||
access_log /dev/stdout;
|
||||
error_log /dev/stderr warn;
|
||||
|
||||
resolver 127.0.0.11 valid=2s ipv6=off;
|
||||
|
||||
upstream api_backend {
|
||||
zone api_backend 64k;
|
||||
server api:8080 resolve max_fails=3 fail_timeout=2s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
client_max_body_size 1m;
|
||||
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_connect_timeout 1s;
|
||||
proxy_send_timeout 5s;
|
||||
proxy_read_timeout 5s;
|
||||
|
||||
# Do not retry non-idempotent requests transparently. The client
|
||||
# repeats an uncertain POST with the same Idempotency-Key, which is
|
||||
# the contract-level guarantee across replicas. A 503 produced by
|
||||
# the application (dependency outage) is passed through, not turned
|
||||
# into an opaque LB 502; only connection/5xx gateway failures retry.
|
||||
proxy_next_upstream error timeout http_502 http_504;
|
||||
proxy_next_upstream_tries 2;
|
||||
proxy_next_upstream_timeout 3s;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user