оценка 4

This commit is contained in:
2026-10-23 16:20:43 +03:00
parent 34618bd423
commit 5300a1a1e0
18 changed files with 1861 additions and 29 deletions
+37 -1
View File
@@ -17,7 +17,7 @@ http {
upstream api_backend {
zone api_backend 64k;
least_conn;
server api:8080 resolve max_fails=1 fail_timeout=1s;
server api:8080 resolve max_fails=2 fail_timeout=2s;
}
server {
@@ -31,6 +31,42 @@ http {
add_header X-Frame-Options "DENY" always;
add_header Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always;
# Message creation carries an Idempotency-Key. It is therefore safe to
# retry a POST on another replica when the selected backend is draining.
location ~ ^/api/v1/chats/[^/]+/messages$ {
proxy_pass http://api_backend;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_set_header Cookie "";
proxy_connect_timeout 1s;
proxy_send_timeout 20s;
proxy_read_timeout 20s;
proxy_next_upstream error timeout http_502 http_503 http_504 non_idempotent;
proxy_next_upstream_tries 3;
}
location ~ ^/web-api/v1/chats/[^/]+/messages$ {
rewrite ^/web-api/(.*)$ /api/$1 break;
proxy_pass http://api_backend;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_set_header Authorization $web_authorization;
proxy_set_header Cookie "";
proxy_connect_timeout 1s;
proxy_send_timeout 20s;
proxy_read_timeout 20s;
proxy_next_upstream error timeout http_502 http_503 http_504 non_idempotent;
proxy_next_upstream_tries 3;
}
location /api/ {
proxy_pass http://api_backend;
proxy_http_version 1.1;