-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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