Last active
March 13, 2020 15:38
-
-
Save apex-omontgomery/97a834b68fcbff84cd46cf648f644efc to your computer and use it in GitHub Desktop.
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
location /api_thing/api { | |
if (-f /etc/nginx/maint_mode/api_thing) { | |
return 503; | |
} | |
- limit_req zone=api_thing_servers burst=2000 nodelay; | |
+ limit_req zone=api_thing_servers0 burst=2000 nodelay; | |
+ limit_req zone=api_thing_servers1 burst=4000 nodelay; | |
+ limit_req zone=api_thing_servers2 burst=1000 nodelay; | |
client_max_body_size 1m; | |
} |
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
-limit_req_zone $http_x_forwarded_for zone=api_thing_servers:16m rate=10r/s; | |
+# Rate limit zones per IP address | |
+geo $http_x_forwarded_for $geo_api_thing_servers { | |
+ default 0; | |
+ 1.3.2.2 1; | |
+ 5.6.3.5 1; | |
+ 1.2.3.4 2; | |
+ 6.5.4.3 2; | |
+} | |
+ | |
+map $geo_api_thing_servers $geo_api_thing_servers_key0 { | |
+ 0 $http_x_forwarded_for; | |
+ 1 ''; | |
+ 2 ''; | |
+} | |
+ | |
+map $geo_atlas_servers $geo_atlas_servers_key1 { | |
+ 0 ''; | |
+ 1 $http_x_forwarded_for; | |
+ 2 ''; | |
+} | |
+ | |
+map $geo_api_thing_servers $geo_api_thing_servers_key2 { | |
+ 0 ''; | |
+ 1 ''; | |
+ 2 $http_x_forwarded_for; | |
+} | |
+ | |
+limit_req_zone $geo_api_thing_servers_key0 zone=ageo_api_thing_servers0:16m rate=1000r/s; | |
+limit_req_zone $geo_api_thing_servers_key1 zone=geo_api_thing_servers1:16m rate=3000r/s; | |
+limit_req_zone $geo_api_thing_servers_key2 zone=geo_api_thing_servers2:16m rate=500r/s; | |
upstream api_thing_servers { | |
least_conn; | |
server hostname1.company.com:8080; | |
server hostname2.company.com:8080; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment