nginx limit request to location based on sent bytes

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a location with static files, served when manifest file changed, so I want to count number of bytes_sent from this location and if rate of number is higher than N, to answer 304 for the manifest file (in case of 'if-none-match' header is present), so it would reduce spikes when application updated, making clients to update slower (we have about 1k/s request ratio for manifest updates).
I checked rate_limit, but it seems can't limit by bytes_sent and also it's "measure" and "block" parts are in the same directive, so I can't block access to manifest location based on static files sent. Also I not sure if it is a good way to rewrite 40x error to 304 using named location.
I checked the lua scripting, it looks promisable, but I not found a good way to run the script worker permanently and reduce bytes in limit bucket each second.
What other direction you would suggest to solve the problem ?
nginx
add a comment |Â
up vote
0
down vote
favorite
I have a location with static files, served when manifest file changed, so I want to count number of bytes_sent from this location and if rate of number is higher than N, to answer 304 for the manifest file (in case of 'if-none-match' header is present), so it would reduce spikes when application updated, making clients to update slower (we have about 1k/s request ratio for manifest updates).
I checked rate_limit, but it seems can't limit by bytes_sent and also it's "measure" and "block" parts are in the same directive, so I can't block access to manifest location based on static files sent. Also I not sure if it is a good way to rewrite 40x error to 304 using named location.
I checked the lua scripting, it looks promisable, but I not found a good way to run the script worker permanently and reduce bytes in limit bucket each second.
What other direction you would suggest to solve the problem ?
nginx
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a location with static files, served when manifest file changed, so I want to count number of bytes_sent from this location and if rate of number is higher than N, to answer 304 for the manifest file (in case of 'if-none-match' header is present), so it would reduce spikes when application updated, making clients to update slower (we have about 1k/s request ratio for manifest updates).
I checked rate_limit, but it seems can't limit by bytes_sent and also it's "measure" and "block" parts are in the same directive, so I can't block access to manifest location based on static files sent. Also I not sure if it is a good way to rewrite 40x error to 304 using named location.
I checked the lua scripting, it looks promisable, but I not found a good way to run the script worker permanently and reduce bytes in limit bucket each second.
What other direction you would suggest to solve the problem ?
nginx
I have a location with static files, served when manifest file changed, so I want to count number of bytes_sent from this location and if rate of number is higher than N, to answer 304 for the manifest file (in case of 'if-none-match' header is present), so it would reduce spikes when application updated, making clients to update slower (we have about 1k/s request ratio for manifest updates).
I checked rate_limit, but it seems can't limit by bytes_sent and also it's "measure" and "block" parts are in the same directive, so I can't block access to manifest location based on static files sent. Also I not sure if it is a good way to rewrite 40x error to 304 using named location.
I checked the lua scripting, it looks promisable, but I not found a good way to run the script worker permanently and reduce bytes in limit bucket each second.
What other direction you would suggest to solve the problem ?
nginx
nginx
edited Sep 27 at 14:36
asked Sep 27 at 14:23
zb'
14619
14619
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471838%2fnginx-limit-request-to-location-based-on-sent-bytes%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password