How to install Shoutcast Published: Jan 18, 2007
  • Rating


Limit the amount of downloads at the same time from and IP address - what a great idea to save yourself some bandwidth costs. It seems that no one is using it, we tried it and love it using mod_limitipconn.c

Limit IP downloads in Apache – Save Bandwidth

Blocking and preventing bandwidth abusers in Apache isn’t an easy task and no one seems to talk about it. We all just leave our websites open for someone to download as many things from the site, at the same time, as the server will allow. I’ve seen some people downloading up to 20 videos at the same time on one of my other sites. Growing tired of kids constantly abusing downloads I decided to see what options I had and came up with some great solutions.

If you have a site with large media such as videos, images or documents then you should read this and think about implementing it. It took me about 20 minutes to figure out, now that I’ve done the brute work it should take you 10 or so minutes.

Preventing Bandwidth Abuse

Instead of using the common talked about hotlinking method I wanted something at the server level which is more reliable. Hotlinking is basically a mod_rewrite .htaccess file that prevents other sites from putting images that are hosted on your server, on their site therefore using your bandwidth.

I wanted to limit the amount of downloads per IP from a visitor on my actual site, meaning someone could only download X number of things at once, instead of unlimited.

After some research I found an Apache module called: mod_limitipconn.c

About LimitIPConn
“This is the distribution page for the Apache module mod_limitipconn.c, which allows web server administrators to limit the number of simultaneous downloads permitted from a single IP address.”
Official site:

Sweet, ok well does this thing work with Cpanel…. Yes, yes it does =)

Test System For this Tutorial
Red Hat Enterprise 3
Cpanel 10.8
Apache 1.3, MySQL 4.1 , PHP 4.4

You can limit a specific number of downloads per IP in the Apache configuration file (httpd.conf) and have different rules for each directory if you want. So if you have a directory called /videos you can create a ruleset for that directory in particular limiting the concurrent downloads to 1 for example. Then you can create another rule for a directory like /archive which you can limit image downloads to 5, there are all kinds of things you can set and lots of rules available!

Understanding the limitipconn Rules
There are many different configurations you can use for this, I’ll go over a few ones I think would be more useful.

Example configuration:


ExtendedStatus On

# Only needed if the module is compiled as a DSO
LoadModule limitipconn_module lib/apache/
AddModule mod_limitipconn.c

<IfModule mod_limitipconn.c>
    <Location /somewhere>
 MaxConnPerIP 3
 # exempting images from the connection limit is often a good
 # idea if your web page has lots of inline images, since these
 # pages often generate a flurry of concurrent image requests
 NoIPLimit image/*

    <Location /mp3>
 MaxConnPerIP 1
 # In this case, all MIME types other than audio/mpeg and video*
 # are exempt from the limit check
 OnlyIPLimit audio/mpeg video


Installing mod_limitipconn.c
Installing this was quick and easy. Login to your server through shell as the root user.

# wget tar xzvf mod_limitipconn-0.04.tar.gz
# cd mod_limitipconn-0.04
# vi Makefile
APXS = apxs
APXS = /usr/local/apache/bin/apxs

#make install

This adds the module to httpd.conf and backs up the old configuration from

# vi /usr/local/apache/conf/httpd.conf
It should have added the following:

LoadModule limitipconn_module libexec/
AddModule mod_limitipconn.c

Now we need to setup the configuration for the site you want to add the limits to. Search the domain you want and go to the configuration for it in httpd.conf

You should be at the part like this:

<VirtualHost IP HERE>

Add the following configuration that you want, this restricts 2 directories I have on my site to prevent users from downloading more than 1 video at a time, I have 2 separate rules.

<IfModule mod_limitipconn.c>
    <Location /videos>
        MaxConnPerIP 1
        # In this case, all MIME types other than audio/mpeg and video*
        # are exempt from the limit check
        OnlyIPLimit audio/mpeg video

    <Location /forums/media/data>
        MaxConnPerIP 1
        # In this case, all MIME types other than audio/mpeg and video*
        # are exempt from the limit check
        OnlyIPLimit audio/mpeg video


So my whole entry for the domain looks like this:

<VirtualHost IPHERE>
DocumentRoot /home/domain/public_html
BytesLog domlogs/
<IfModule mod_php4.c>
php_admin_value open_basedir "/home/domain:/usr/lib/php:/usr/local/lib/php:/tmp"
<IfModule mod_limitipconn.c>
    <Location /videos>
        MaxConnPerIP 1
        # In this case, all MIME types other than audio/mpeg and video*
        # are exempt from the limit check
        OnlyIPLimit audio/mpeg video

    <Location /forums/media/data>
        MaxConnPerIP 1
        # In this case, all MIME types other than audio/mpeg and video*
        # are exempt from the limit check
        OnlyIPLimit audio/mpeg video

User domain
Group domain
CustomLog domlogs/ combined
ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/

Save httpd.conf

Test Apache Configuration
# apachectl configtest start
Make sure it comes back ok without errors

# /scripts/restartsrv_httpd

Apache will restart. Try it out. Go to your limited directory and try to download 2 things (2 depends on your IP limit you set). You should get forwarded to a 503 Temporary Service page. We can customize that as well =)

Customizing the 503 Temporary Service Page
FTP to your webspace and edit your public_html/.htaccess file

Add the following to the top:
ErrorDocument 503

Save the file and upload it.

Create a page called bandwidth.php or html, or whatever you want. Put a message saying you’re preventing bandwidth abuse and limiting downloads to 1 at a time.

Make sure everything is working well and go relax, you did a good job and managed to save your server a lot of bandwidth and yourself some cash!

About the Author:
Steven Leggett is the editor of the server resource and hosting tutorial site, and specializes in system administration and web development.


  • Rating


Related Articles

Comments (12)

  • Gravatar - Mateus
    Mateus 21:38, March 5, 2007
    There is any problem on running Shoutcast on a Web shared hosting?<br />
    <br />
  • Gravatar - 18:31, April 24, 2007
    if your hosting allows SSH connection yes you can.
  • Gravatar - Safira
    Safira 22:02, July 1, 2007
    How do I restart the server. I have been trying the cd / radio ad then ls and this is what i am getting ./ ../ bin/ checkvirtfs* dev/ etc/ home/ lib/ proc/ tmp/ usr/ var/<br />
    <br />
    <br />
    help with what to do next please
  • Gravatar - Rich
    Rich 14:49, November 3, 2007
    I have shoutcast set up, but am having trouble sourcing the soundcard to transmit from. I have it set as playfile /dev/audio, and it does not work. If I type playfile /filename.mp3 it works fine. Any suggestions would be appreciated.<br />
    <br />
  • Gravatar - Ranch
    Ranch 21:07, December 1, 2007
    How do I install to broadcast in multiple bit rates?<br />
    <br />
    IE:<br />
    56Kbps<br />
  • Gravatar - dave
    dave 20:32, December 20, 2007
    you would need to run 2 shoutcast servers, one at 56kbps and one at 128kbps
  • Gravatar - botakedan
    botakedan 09:07, March 22, 2008
    how to run 2 or more broadcaster in one server ?
  • Gravatar - Rich
    Rich 08:06, July 4, 2008
    Just have multiple config files.
  • Gravatar - James Rippey
    James Rippey 15:45, April 12, 2009
    Please anyone help with shoutcast set-up , I downloaded proper files from shoutcast along with winamp , from there I am lost . I cant broadcast , my IP tells me i can use my server for outgoing , i hope my server addrees is okay . Anyone please help and respond by e-mail too , any help would be greatly appreciated . jim
  • Gravatar - michel
    michel 22:01, August 18, 2009
    [root@server ~]# cd /downloads<br />
    [root@server downloads]# wget<br />
    --22:07:34--<br />
    Resolving<br />
    Connecting to||:80... connected.<br />
    HTTP request sent, awaiting response... 404 /shoutcast/downloads/sc1-9-2/shoutcast-1-9-2-linux-glibc6.tar.gz<br />
    22:07:35 ERROR 404: /shoutcast/downloads/sc1-9-2/shoutcast-1-9-2-linux-glibc6.tar.gz.<br />
    <br />
    [root@server downloads]# <br />
    <br />
    <br />
    Help me plz
  • Gravatar - sean
    sean 16:01, September 22, 2009
    thanks for the info works fine but i want to know how to stop the server ... i got it to start fine .... and is there any way to add a conntrol pannel ..????
  • Gravatar - Gorgui GUEYE
    Gorgui GUEYE 10:49, December 2, 2009
    Anyone help me.<br />
    I installed shoutcast but by starting the shoutcast unsing ./sc_serv sc_serv.conf I get error message like :FATAL ERROR! Some other process is using this port!<br />

Add Your Thoughts is a hosting directory, not a web host.

Copyright © 1998-2019