Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Aug 1 '09 at 14:52

This question came from our site for professional and enthusiast programmers.

2 Answers 2

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.

http://codee.pl/cband.html

share|improve this answer

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

Sample code:

location /download/ {
   limit_rate  10k;
}
share|improve this answer

Your Answer

 
discard

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.