forked from mtusi2026/mtusi2026lab7
Implement lab 7 security and mTLS
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
worker_processes 1;
|
||||
# A single worker keeps the round-robin counter shared and deterministic for
|
||||
# the lab's small replica count; a production LB would instead rely on a
|
||||
# shared/consistent balancing policy across workers.
|
||||
events { worker_connections 1024; }
|
||||
|
||||
http {
|
||||
upstream messenger_api {
|
||||
# Passive health check: a backend failing 1 probe is removed for 3s,
|
||||
# which keeps failover detection well under the 10s budget.
|
||||
server api1:8080 max_fails=1 fail_timeout=3s;
|
||||
server api2:8080 max_fails=1 fail_timeout=3s;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8443 ssl;
|
||||
ssl_certificate /etc/nginx/certs/server.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/server.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_verify_client off;
|
||||
# Slightly above the app's own 10 MiB attachment limit so the API --
|
||||
# not Nginx's default HTML error page -- produces the contract's
|
||||
# JSON 413 envelope. The API still enforces the exact byte budget.
|
||||
client_max_body_size 11M;
|
||||
|
||||
location / {
|
||||
proxy_pass https://messenger_api;
|
||||
proxy_ssl_verify on;
|
||||
proxy_ssl_trusted_certificate /etc/nginx/certs/ca.crt;
|
||||
proxy_ssl_verify_depth 2;
|
||||
proxy_ssl_certificate /etc/nginx/certs/lb-client.crt;
|
||||
proxy_ssl_certificate_key /etc/nginx/certs/lb-client.key;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name messenger_api;
|
||||
proxy_connect_timeout 1s;
|
||||
proxy_read_timeout 5s;
|
||||
proxy_next_upstream error timeout http_502 http_503 http_504;
|
||||
proxy_next_upstream_tries 2;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user