ops: Cache testnet electrs endpoints for minimum of 1s

This commit is contained in:
wiz 2024-11-01 21:20:54 +09:00
parent 0a9703f164
commit e75f913af3
No known key found for this signature in database
GPG Key ID: A394E332255A6173

View File

@ -47,10 +47,10 @@ location /testnet/api/block/ {
rewrite ^/testnet/api/(.*) /$1 break;
try_files /dev/null @esplora-testnet-api-cache-forever;
}
# other API responses cannot be cached
# we cache for 1s to mitigate DoS attacks
location /testnet/api/ {
rewrite ^/testnet/api/(.*) /$1 break;
try_files /dev/null @esplora-testnet-api-cache-disabled;
try_files /dev/null @esplora-testnet-api-cache-minimal;
}
###########
@ -160,3 +160,20 @@ location @esplora-testnet-api-cache-forever {
expires 30d;
}
location @esplora-testnet-api-cache-minimal {
proxy_pass $esploraTestnet;
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_cache_background_update off;
proxy_cache_use_stale error;
proxy_cache apihot;
proxy_cache_valid 200 1s;
proxy_redirect off;
expires 1s;
}