limit_req_zone: How to apply only to some requests containing some string in the URL?

Brian08275660 nginx-forum at nginx.us
Thu Oct 24 13:17:58 UTC 2013


Hi Francis,

Thanks a lot! You saved me probably a couple of days of research. It is
working now!

I did this:

The user will send my a "capacity" parameter, with a value of 2X or 3X or 4X
or......(etc)

	map $arg_capacity $2X_key{~*2X $http_x_forwarded_for;default "";}
	map $arg_capacity $3X_key{~*3X $http_x_forwarded_for;default "";}
	map $arg_capacity $4X_key{~*4X $http_x_forwarded_for;default "";}
	map $arg_capacity $5X_key{~*5X $http_x_forwarded_for;default "";}
	map $arg_capacity $6X_key{~*6X $http_x_forwarded_for;default "";}
	map $arg_capacity $7X_key{~*7X $http_x_forwarded_for;default "";}
	map $arg_capacity $8X_key{~*8X $http_x_forwarded_for;default "";}
	map $arg_capacity $9X_key{~*9X $http_x_forwarded_for;default "";}
	map $arg_capacity $10X_key{~*10X $http_x_forwarded_for;default "";}

	limit_req_zone $2X_key zone=2X:1m rate=600r/m;
	limit_req_zone $3X_key zone=3X:1m rate=900r/m;
	limit_req_zone $4X_key zone=4X:1m rate=1200r/m;
	limit_req_zone $5X_key zone=5X:1m rate=1500r/m;
	limit_req_zone $6X_key zone=6X:1m rate=1800r/m;
	limit_req_zone $7X_key zone=7X:1m rate=2100r/m;
	limit_req_zone $8X_key zone=8X:1m rate=2400r/m;
	limit_req_zone $9X_key zone=9X:1m rate=2700r/m;
	limit_req_zone $10X_key zone=10X:1m rate=3000r/m;

	limit_req zone=2X burst=600;
	limit_req zone=3X burst=900;
	limit_req zone=4X burst=1200;
	limit_req zone=5X burst=1500;
	limit_req zone=6X burst=1800;
	limit_req zone=7X burst=2100;
	limit_req zone=8X burst=2400;
	limit_req zone=9X burst=2700;
	limit_req zone=10X burst=3000;

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,244015,244064#msg-244064



More information about the nginx mailing list