Yes, this can be done.
Write a G-WAN handler to extract the X-Accel-Limit-Rate
HTTP header. Then enforce this policy by using the throttle_reply()
G-WAN API call documented here.
An example available called throttle.c might help you further.
The throttle_reply()
G-WAN function lets you apply throttling on a global basis or per connection, so you will just apply the relevant throttling values for either IP addresses
or authenticated users
, depending on your needs.
throttle_reply()
can change the download speed dynamically during the lifespan of each connection so you can slow-down old connections and create new ones with an adaptive download rate.
Of course, this can be enforced on a per client IP address (or cookie, or even ISP/Datacenter AS record) to deal with huge workloads.