Skip to content

Instantly share code, notes, and snippets.

@felipe3dfx
Created July 16, 2021 20:55
Show Gist options
  • Save felipe3dfx/f19bf5816222eb18c76693cf95d59d56 to your computer and use it in GitHub Desktop.
Save felipe3dfx/f19bf5816222eb18c76693cf95d59d56 to your computer and use it in GitHub Desktop.
Add whitelist ip to limit request zone nginx
geo $limited {
default 1;
xxx.xxx.xxx/xx 0;
}
map $limited $limit {
1 $binary_remote_addr;
0 "";
}
limit_conn_zone $limit zone=conn_limit_per_ip:10m;
limit_req_zone $limit zone=req_limit_per_ip:10m rate=5r/s;
# yo can test it using salvo: salvo https://example.com -c 200 -d 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment