Bandwidth limiting

Discussion in 'Apache' started by xxsAm, Aug 7, 2007.

  1. #1
    I run a chain of proxy sites and bandwidth is becoming a major problem. What I'm looking to do is to find a module that allows me to block a user's ip if they exceed a limit of say 50mb for the day, and then forward them to a site stating that they have been blocked for 24 hours. Anyone know of a module or addon that can do this?
     
    xxsAm, Aug 7, 2007 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    http://www.cohprog.com/mod_bandwidth.html


    that might be what your looking for

    also make sure that your not getting relay links at all

    that's where a site (usally porn) links all it's images via a proxy site to the images, so that the site itself can't get blocked, and has low bandwidth usage.
     
    powerspike, Aug 7, 2007 IP
  3. xxsAm

    xxsAm Active Member

    Messages:
    464
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #3

    I assume you are referring to hotlinking. I have hotlinking disabled within phproxy.
     
    xxsAm, Aug 7, 2007 IP
  4. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    there are ways around it, if you check your referer logs, if there is a high amount of hits from one place you know they are doing it =)
     
    powerspike, Aug 7, 2007 IP
  5. xxsAm

    xxsAm Active Member

    Messages:
    464
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #5
    How can i prevent the ways around it? Also where is the referrer log located? I googled it but the place where i found it is suppose to reside it is not there(/var/log/apache/referer.log).
     
    xxsAm, Aug 8, 2007 IP
  6. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Logs depend on the setup of the server
    you should have some type of stats package enabled (like awstats)

    most stats packages have a referer section in them so you could see where traffic is coming from.
    The code you posted in the other thread, try moving down the code to after the url is decoded, if that doesn't work
    you can find out which referers are sending the hotlinks and and put in some code that kills the script if it comes from that source.

    It's been a while since i have played with proxy's so am unsure on where it would be, and i used cgiproxy at the time so that would be even less help =)
     
    powerspike, Aug 9, 2007 IP
  7. xxsAm

    xxsAm Active Member

    Messages:
    464
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    60
    #7
    I used the below code and its worked wonders the past 24 hours. Bandwidth per hour went from around 10-15 to 2-3. Just placed it at the top of index.php

    /*
    PHProxy bandwidth MOD 1.1
    This MOD will stop any hotlinking via PHProxy, even if the
    clients referer is not set!
    Check out proxywebsite.org if you want to try hotlinking.
    */
    
    // allow hotlinking from these sites, seperate by comma (make sure you eneter your site's domains)
    $domains="www.yourdomain.com,yourdomain.com";
    
    // convert domains into an array
    $domains=explode(",",$domains);
    
      // if there is a request:
      if($_GET['q']!="")
      {
      // get referer
      $referer=explode("/",($_SERVER['HTTP_REFERER']));
        // if the referer is not allowed:
        if(!in_array($referer[2],$domains))
        {
        // redirect to homepage and finish script
        header("Location: http://".$domains[0]."/");
    
        exit();
        }
      }
    
    /*
    END MOD
    */  
    Code (markup):
     
    Last edited by a moderator: Sep 28, 2025
    xxsAm, Aug 10, 2007 IP