some changes

This commit is contained in:
2026-11-25 18:52:25 +03:00
parent 883b3e0305
commit 734e36fc19
9 changed files with 196 additions and 175 deletions
+41
View File
@@ -0,0 +1,41 @@
global
maxconn 256
nbthread 1
ssl-default-bind-options ssl-min-ver TLSv1.2
ssl-default-server-options ssl-min-ver TLSv1.2
defaults
mode http
timeout connect 3s
timeout client 90s
timeout server 90s
timeout check 3s
resolvers docker
nameserver dns 127.0.0.11:53
hold valid 2s
hold obsolete 1s
hold nx 1s
frontend ingress
bind :8443 ssl crt /identity/bundle.pem
stick-table type ip size 32k expire 1m store http_req_rate(15s)
acl login_path path -i /api/v1/auth/sessions
http-request set-var(txn.rid) uuid()
http-request track-sc0 src if METH_POST login_path
http-request return status 429 content-type application/json lf-string '{"error":{"code":"rate_limited","message":"Login limit","request_id":"%[var(txn.rid)]"}}' hdr X-Request-Id %[var(txn.rid)] hdr X-Instance-Id ingress hdr Retry-After 15 if METH_POST login_path { sc_http_req_rate(0) gt 15 }
http-request return status 413 content-type application/json lf-string '{"error":{"code":"payload_too_large","message":"Body exceeds limit","request_id":"%[var(txn.rid)]"}}' hdr X-Request-Id %[var(txn.rid)] hdr X-Instance-Id ingress if { req.hdr_val(content-length) gt 10485760 }
# The upload handler counts decoded body bytes for streaming uploads.
acl upload_path path_reg ^/api/v1/chats/[^/]+/attachments$
http-request return status 411 if { req.hdr(transfer-encoding) -m found } !upload_path
http-request deny deny_status 404 if { path_beg /actuator }
http-request del-header X-User-Id
http-request set-header X-Forwarded-For %[src]
default_backend replicas
backend replicas
balance roundrobin
option httpchk
http-check send meth GET uri /health/ready ver HTTP/1.1 hdr Host api
http-check expect status 200
server-template node 1-8 api:8443 ssl verify required ca-file /identity/ca.crt crt /identity/bundle.pem verifyhost api sni str(api) check-sni api check inter 2s fall 2 rise 1 resolvers docker resolve-prefer ipv4 init-addr none
-51
View File
@@ -1,51 +0,0 @@
worker_processes 1;
events { worker_connections 1024; }
http {
access_log off;
resolver 127.0.0.11 valid=2s ipv6=off;
upstream messenger {
zone replicas 64k;
server api:8443 resolve max_fails=1 fail_timeout=2s;
}
map "$request_method:$uri" $login_key {
default "";
"POST:/api/v1/auth/sessions" $binary_remote_addr;
}
limit_req_zone $login_key zone=login:1m rate=1r/s;
server {
listen 8443 ssl;
ssl_certificate /identity/cert.pem;
ssl_certificate_key /identity/key.pem;
ssl_protocols TLSv1.2 TLSv1.3;
client_max_body_size 10m;
limit_req zone=login burst=15 nodelay;
limit_req_status 429;
error_page 429 = @rate;
error_page 413 = @large;
location @rate {
default_type application/json;
add_header X-Request-Id $request_id always;
add_header X-Instance-Id ingress always;
add_header Retry-After 1 always;
return 429 '{"error":{"code":"rate_limited","message":"Login limit","request_id":"$request_id"}}';
}
location @large {
default_type application/json;
add_header X-Request-Id $request_id always;
add_header X-Instance-Id ingress always;
return 413 '{"error":{"code":"payload_too_large","message":"Body exceeds limit","request_id":"$request_id"}}';
}
location /actuator { return 404; }
location / {
proxy_pass https://messenger;
proxy_ssl_certificate /identity/cert.pem;
proxy_ssl_certificate_key /identity/key.pem;
proxy_ssl_trusted_certificate /identity/ca.crt;
proxy_ssl_verify on;
proxy_ssl_server_name on;
proxy_ssl_name api;
proxy_set_header X-User-Id "";
proxy_set_header X-Forwarded-For $remote_addr;
}
}
}