forked from mtusi2026/mtusi2026lab7
feat: core func lab7
This commit is contained in:
+36
-5
@@ -7,6 +7,20 @@ events {
|
||||
}
|
||||
|
||||
http {
|
||||
limit_req_zone $binary_remote_addr zone=auth_per_ip:1m rate=5r/s;
|
||||
limit_req_zone $server_name zone=auth_total:1m rate=20r/s;
|
||||
limit_req_status 429;
|
||||
ssl_certificate /run/server/tls.crt;
|
||||
ssl_certificate_key /run/server/tls.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
proxy_ssl_certificate /run/identity/tls.crt;
|
||||
proxy_ssl_certificate_key /run/identity/tls.key;
|
||||
proxy_ssl_trusted_certificate /run/ca/ca.crt;
|
||||
proxy_ssl_verify on;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_name api;
|
||||
proxy_ssl_session_reuse off;
|
||||
resolver 127.0.0.11 valid=2s ipv6=off;
|
||||
resolver_timeout 1s;
|
||||
|
||||
@@ -60,10 +74,17 @@ http {
|
||||
proxy_next_upstream_timeout 5s;
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
listen 8080 ssl;
|
||||
server_name localhost;
|
||||
|
||||
location ~ ^/api/v1/(auth/sessions|users)/?$ {
|
||||
limit_req zone=auth_per_ip burst=16 nodelay;
|
||||
limit_req zone=auth_total burst=32 nodelay;
|
||||
proxy_pass https://api;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://api;
|
||||
proxy_pass https://api;
|
||||
}
|
||||
|
||||
# Загрузка вложения. Лимит LB чуть больше лимита API (10 MiB): тело
|
||||
@@ -80,27 +101,37 @@ http {
|
||||
client_max_body_size 11m;
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 45s;
|
||||
proxy_pass http://api;
|
||||
proxy_pass https://api;
|
||||
}
|
||||
|
||||
error_page 502 503 504 = @unavailable;
|
||||
error_page 413 = @too_large;
|
||||
error_page 429 = @rate_limited;
|
||||
|
||||
include /etc/nginx/errors.conf;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8081;
|
||||
listen 8081 ssl;
|
||||
server_name localhost;
|
||||
|
||||
# Реплика api-short-ttl только для make test-expiry (профиль expiry):
|
||||
# адрес резолвится на каждый запрос, без профиля — 503 от LB
|
||||
location ~ ^/api/v1/(auth/sessions|users)/?$ {
|
||||
limit_req zone=auth_per_ip burst=16 nodelay;
|
||||
limit_req zone=auth_total burst=32 nodelay;
|
||||
set $api_short_ttl https://api-short-ttl:8080;
|
||||
proxy_pass $api_short_ttl;
|
||||
}
|
||||
|
||||
location / {
|
||||
set $api_short_ttl http://api-short-ttl:8080;
|
||||
set $api_short_ttl https://api-short-ttl:8080;
|
||||
proxy_pass $api_short_ttl;
|
||||
}
|
||||
|
||||
error_page 502 503 504 = @unavailable;
|
||||
error_page 413 = @too_large;
|
||||
error_page 429 = @rate_limited;
|
||||
|
||||
include /etc/nginx/errors.conf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user