Skip to content

Instantly share code, notes, and snippets.

@aamsur-mkt
Forked from skaag/limt_req_zone_whitelist
Last active November 1, 2023 12:23
Show Gist options
  • Save aamsur-mkt/7bf4df9b9ab6ecfb35ad9b3a39dc7504 to your computer and use it in GitHub Desktop.
Save aamsur-mkt/7bf4df9b9ab6ecfb35ad9b3a39dc7504 to your computer and use it in GitHub Desktop.
A way to whitelist certain IP ranges from limit_req_zone in nginx
geo $whitelist_ip {
default 1;
# Your office ip
127.0.0.1/32 0;
}
map $whitelist_ip $default_limit {
1 $binary_remote_addr;
0 "";
}
map $whitelist_ip $office_limit {
0 $binary_remote_addr;
1 "";
}
limit_req_zone $default_limit zone=openzone:10m rate=30r/s;
limit_req_zone $office_limit zone=officezone:10m rate=100r/s;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment