Skip to content

Instantly share code, notes, and snippets.

@supairish
Created May 30, 2014 23:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save supairish/748c85552b2f7047a36a to your computer and use it in GitHub Desktop.
Save supairish/748c85552b2f7047a36a 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