Files
mtusi2026lab7/infra/nginx.conf
T
ejur22 d995f98446
Skeleton contracts / contracts (pull_request) Canceled after 0s
Lab 7
2026-11-27 20:47:58 +03:00

80 lines
2.3 KiB
Nginx Configuration File

# Public TLS ingress. Terminates client TLS with the project CA leaf and
# re-encrypts to every API replica over mandatory mTLS using the dedicated LB
# client identity. The API has no published port; its own nginx terminator
# verifies the client cert chain AND the CN=lb identity.
worker_processes auto;
events {
worker_connections 2048;
}
http {
sendfile on;
keepalive_timeout 30;
server_tokens off;
access_log /dev/stdout;
error_log /dev/stderr warn;
upstream api_backend {
server api:8443;
}
# Minimal loopback-only liveness listener (not published); it cannot reach
# the business API without mTLS, so it is not a bypass.
server {
listen 127.0.0.1:8080;
server_name _;
access_log off;
location = /health/live {
return 200 "ok\n";
}
location / {
return 404;
}
}
server {
listen 8443 ssl;
server_name _;
ssl_certificate /run/secrets/lb.crt;
ssl_certificate_key /run/secrets/lb.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
# One attachment (<=10 MiB) plus JSON overhead.
client_max_body_size 12m;
proxy_http_version 1.1;
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 https;
proxy_connect_timeout 5s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
# Mandatory mTLS to the API replicas with server verification.
proxy_ssl_verify on;
proxy_ssl_verify_depth 2;
proxy_ssl_trusted_certificate /run/secrets/ca.crt;
proxy_ssl_certificate /run/secrets/lb-client.crt;
proxy_ssl_certificate_key /run/secrets/lb-client.key;
proxy_ssl_server_name on;
proxy_ssl_name api;
proxy_ssl_protocols TLSv1.2 TLSv1.3;
proxy_next_upstream error timeout http_502 http_503 http_504;
proxy_next_upstream_tries 2;
location /health/live {
access_log off;
proxy_pass https://api_backend;
}
location / {
proxy_pass https://api_backend;
}
}
}