Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am planning to limit user bandwidth. I came across post_action directive in core module and thinking if I can get response size served by nginx and send it to code using post_action.

Any ideas how can I do that?

share|improve this question
up vote 1 down vote accepted

nginx sets its $body_bytes_sent variable to the size of the HTTP response.

share|improve this answer
There's $bytes_sent too which includes headers. See this answer: – KajMagnus Jul 6 at 5:17

There's a built-in solution to limit user bandwith in the HttpCoreModule of nginx. Let's say for example that you want to limit bandwith to 20kB/s:

set $limit_rate 20k;
share|improve this answer
I want to limit bandwidth per user per month – cmnajs Nov 29 '12 at 8:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.