haproxy error fixed

This commit is contained in:
2026-11-09 19:26:17 +03:00
parent 0346937847
commit c594b88a46
+9 -2
View File
@@ -47,8 +47,15 @@ defaults
frontend public
bind :8080
monitor-uri /lb/health
# Attachment uploads are raw bytes, up to 10 MiB. Larger declared bodies never reach an API replica.
http-request deny deny_status 413 if { req.hdr_val(content-length) gt 10485760 }
# Attachment uploads are raw bytes, up to 10 MiB. A larger Content-Length is
# rejected here, before the body is read or an API replica is contacted.
# The body matches the API error envelope; request_id echoes a safe client
# X-Request-Id and otherwise stays "lb", like the other gateway errors.
acl upload_too_large req.hdr_val(content-length) gt 10485760
acl safe_request_id req.hdr(X-Request-Id) -m reg ^[A-Za-z0-9._:-]{1,128}$
http-request set-var(txn.reqid) req.hdr(X-Request-Id) if upload_too_large safe_request_id
http-request set-var(txn.reqid) str(lb) if upload_too_large !safe_request_id
http-request return status 413 content-type application/json lf-string "{\"error\":{\"code\":\"payload_too_large\",\"message\":\"Файл больше 10 МиБ\",\"request_id\":\"%[var(txn.reqid)]\"}}" hdr X-Request-Id %[var(txn.reqid)] if upload_too_large
# Message POST carries a mandatory Idempotency-Key, so replaying it on another replica is safe.
# Other POSTs (users, chats, sessions) are retried only when the connection was never established.