Files
mtusi2026lab7-fork/infra/nginx.conf
T

61 lines
2.1 KiB
Nginx Configuration File

worker_processes 1;
pid /tmp/nginx.pid;
worker_shutdown_timeout 6s;
events { worker_connections 1024; }
http {
resolver 127.0.0.11 valid=1s ipv6=off;
resolver_timeout 1s;
log_format lab '$time_iso8601 $request_method $uri $status upstream=$upstream_addr '
'instance=$upstream_http_x_instance_id time=$request_time';
access_log /dev/stdout lab;
error_log /dev/stderr warn;
upstream api {
zone api 64k;
include /tmp/upstreams.conf;
}
server {
listen 8443 ssl;
ssl_certificate /run/tls/server.crt;
ssl_certificate_key /run/tls/server.key;
ssl_protocols TLSv1.2 TLSv1.3;
proxy_ssl_certificate /run/tls/server.crt;
proxy_ssl_certificate_key /run/tls/server.key;
proxy_ssl_trusted_certificate /run/ca/ca.crt;
proxy_ssl_crl /run/ca/crl.pem;
proxy_ssl_verify on;
proxy_ssl_server_name on;
proxy_ssl_name messenger-api;
client_max_body_size 1m;
client_body_timeout 5s;
proxy_http_version 1.1;
proxy_set_header Connection close;
proxy_set_header Host $host;
proxy_set_header X-Request-Id $http_x_request_id;
proxy_connect_timeout 1s;
proxy_read_timeout 5s;
proxy_send_timeout 5s;
proxy_next_upstream error timeout http_502 http_504;
proxy_next_upstream_tries 2;
proxy_next_upstream_timeout 6s;
location ~ ^/api/v1/chats/[^/]+/attachments$ {
# Keep a proxy ceiling above the API limit so the API can return its JSON 413.
client_max_body_size 11m;
proxy_read_timeout 45s;
proxy_send_timeout 30s;
proxy_next_upstream off;
proxy_pass https://api;
}
location ~ ^/api/v1/attachments/[^/]+/content$ {
proxy_buffering off;
proxy_read_timeout 10s;
# A shared S3 outage returns 503 without marking the API itself down.
proxy_next_upstream error timeout http_502 http_504;
proxy_pass https://api;
}
location / {
proxy_pass https://api;
}
}
}