forked from mtusi2026/mtusi2026lab4
63 lines
2.5 KiB
Nginx Configuration File
63 lines
2.5 KiB
Nginx Configuration File
worker_processes 1;
|
|
pid /tmp/nginx.pid;
|
|
error_log /dev/stderr warn;
|
|
worker_shutdown_timeout 5s;
|
|
events { worker_connections 1024; }
|
|
http {
|
|
log_format upstream '$request_method $uri status=$status upstream=$upstream_addr upstream_status=$upstream_status time=$request_time';
|
|
access_log /dev/stdout upstream;
|
|
resolver 127.0.0.11 valid=1s ipv6=off;
|
|
resolver_timeout 1s;
|
|
include /tmp/backends.conf;
|
|
server {
|
|
listen 8080;
|
|
server_tokens off;
|
|
# The API enforces the exact 10 MiB file limit while streaming.
|
|
client_max_body_size 11m;
|
|
client_header_timeout 5s;
|
|
client_body_timeout 10s;
|
|
keepalive_timeout 2s;
|
|
error_page 413 = @payload_too_large;
|
|
error_page 502 504 = @unavailable;
|
|
location @unavailable {
|
|
default_type application/json;
|
|
add_header X-Request-Id $request_id always;
|
|
return 503 '{"error":{"code":"unavailable","message":"Service temporarily unavailable","request_id":"$request_id"}}';
|
|
}
|
|
location @payload_too_large {
|
|
default_type application/json;
|
|
add_header X-Request-Id $request_id always;
|
|
return 413 '{"error":{"code":"payload_too_large","message":"Request body too large","request_id":"$request_id"}}';
|
|
}
|
|
location ~ ^/api/v1/chats/[^/]+/attachments$ {
|
|
proxy_pass http://api_backend;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_connect_timeout 1s;
|
|
proxy_read_timeout 75s;
|
|
proxy_send_timeout 75s;
|
|
proxy_request_buffering off;
|
|
proxy_buffering off;
|
|
# A binary POST has no idempotency key and must not be replayed.
|
|
proxy_next_upstream off;
|
|
}
|
|
location / {
|
|
proxy_pass http://api_backend;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_connect_timeout 1s;
|
|
proxy_read_timeout 8s;
|
|
proxy_send_timeout 8s;
|
|
proxy_request_buffering off;
|
|
proxy_buffering off;
|
|
proxy_next_upstream error timeout http_502 http_503 http_504;
|
|
proxy_next_upstream_tries 2;
|
|
proxy_next_upstream_timeout 9s;
|
|
}
|
|
}
|
|
}
|