I'm hosting an image sharing site and I seem to be running into an unusual problem. I use the Apache module mod_rewrite to make all the urls to each image much shorter than they would be otherwise, but this seems to be preventing other modules such as mod_bw or mod_bandwidth from working, since the user isn't technically requesting to download a file.

My problem occurs when someone uploads a 2mb animated gif. Sometimes the gif will steal all the bandwidth to the server and render my site useless. I need a way to detect when users want to view gifs and then limit their speed to something more reasonable.

The only way I can think about doing this is if there was some Apache module that detected the .gif at the end of the url, and then kicked on the bandwidth limiting. Is this even possible? Or is there something else I can do?


You're looking for mod_cband to do what you need. You wrap it's directives inside a LocationMatch container for .gif files for example. If for some reason you're running an old Apache 1.3 look up mod_bandwidth or mod_throttle instead.



nginx has this function. You can make nginx a reverse proxy for Apache.

Sample code:

location /download/ {
   limit_rate  10k;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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