Files
mtusi2026lab7/infra/nginx/nginx.conf
T
HellsTomatoandCopilot 2ef0299e34
Skeleton contracts / contracts (pull_request) Canceled after 0s
Complete lab7 grade 4 implementation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-06 15:35:53 +03:00

40 lines
1.8 KiB
Nginx Configuration File

# Public TLS terminates here. The next hop is a separate mTLS connection to API.
resolver 127.0.0.11 valid=5s ipv6=off;
upstream api_backend {
zone api_backend 64k;
server api-1:8080 resolve max_fails=3 fail_timeout=10s;
server api-2:8080 resolve max_fails=3 fail_timeout=10s;
keepalive 32;
}
server {
listen 8443 ssl;
server_name localhost;
ssl_certificate /run/secrets/ingress.crt;
ssl_certificate_key /run/secrets/ingress.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:TLS:10m;
client_max_body_size 11m;
client_body_timeout 15s;
proxy_connect_timeout 1s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_http_version 1.1;
proxy_set_header Connection "";
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 https;
# Identity is lb (not merely a certificate from our CA); API additionally allowlists its SAN.
proxy_ssl_certificate /run/secrets/lb.crt;
proxy_ssl_certificate_key /run/secrets/lb.key;
proxy_ssl_trusted_certificate /run/secrets/ca.crt;
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_name api;
proxy_ssl_server_name on;
location / { proxy_pass https://api_backend; proxy_next_upstream error timeout http_503; }
location ~ ^/api/v1/chats/[^/]+/messages$ { proxy_pass https://api_backend; proxy_next_upstream error timeout http_503 non_idempotent; }
error_page 413 = @payload_too_large;
location @payload_too_large { default_type application/json; add_header X-Request-Id $request_id always; return 413 '{"error":{"code":"payload_too_large","message":"payload too large","request_id":"$request_id"}}'; }
}