Exempt localhost from nginx rate limits for Tor and AU usage

This commit is contained in:
wiz 2020-12-03 09:47:39 +09:00
parent e35eb5aad2
commit 6b498b9601
No known key found for this signature in database
GPG Key ID: A394E332255A6173

View File

@ -54,13 +54,23 @@ http {
proxy_cache_path /var/cache/nginx keys_zone=cache:20m levels=1:2 inactive=600s max_size=500m;
types_hash_max_size 2048;
# exempt localhost from rate limit
geo $limited_ip {
default 1;
127.0.0.1 0;
}
map $limited_ip $limited_ip_key {
1 $binary_remote_addr;
0 '';
}
# rate limit requests
limit_req_zone $binary_remote_addr zone=api:5m rate=200r/m;
limit_req_zone $binary_remote_addr zone=electrs:5m rate=2000r/m;
limit_req_zone $limited_ip_key zone=api:5m rate=200r/m;
limit_req_zone $limited_ip_key zone=electrs:5m rate=2000r/m;
limit_req_status 429;
# rate limit connections
limit_conn_zone $binary_remote_addr zone=websocket:10m;
limit_conn_zone $limited_ip_key zone=websocket:10m;
limit_conn_status 429;
map $http_accept_language $header_lang {