Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arenadoon/820e70d8d2e6c90ea8263465e8d92e37 to your computer and use it in GitHub Desktop.
Save arenadoon/820e70d8d2e6c90ea8263465e8d92e37 to your computer and use it in GitHub Desktop.
Whitelist request throttling in Nginx?
http {
map $whitelist $limit {
default $binary_remote_addr;
1 "";
}
limit_conn_zone $limit zone=conn_limit_per_ip:10m;
limit_req_zone $limit zone=req_limit_per_ip:10m rate=5r/s;
server {
set $whitelist "";
if ( $hostname = some_url.com ) {
set $whitelist 1;
}
limit_conn conn_limit_per_ip 10;
limit_req zone=req_limit_per_ip burst=30 nodelay;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment