limiting bandwith by querying mysql possible?

Robert Mueller robm at
Fri Jan 22 06:00:48 MSK 2010

> what i'm trying to do is limit the bandwith for each user that i have in
> a mysqlDB for some mp3.

You might be able to look at the postaction handler. We have something
like this:

    location /xyz {
      proxy_hide_header           X-Rate-User;
      post_action                 @ratepostaction;

    location @ratepostaction {
      set $rateuser $upstream_http_x_rate_user;
      proxy_set_header RateUser $rateuser;
      proxy_set_header RateURI  "$host$request_uri";
      proxy_set_header RateBytes $body_bytes_sent;
      proxy_set_header RateIP $remote_addr;
      proxy_set_header RateStatus $upstream_status;
      proxy_pass_request_body off;
      proxy_pass_request_headers off;
      proxy_pass http://unix:/var/state/ratetrack/ratepostaction:;

To track used bandwidth for each user. The backend sets the X-Rate-User
header in the response, and there's a separate daemon running that
listens on /var/state/ratetrack/ratepostaction to receive the rate data

I'm not sure how this interacts with NginxXSendfile though...


More information about the nginx mailing list