Monthly Archives: January 2012

Controlling your visitors/users bandwidth usage and speed using mod_cband

Again, I’m using my beloved Debian 6 squeeze distribution to test this tutorial.
What is mod_cband? Directly taken from the one that maintain this piece of work:

mod_cband is an Apache 2 module provided to solve the problem of limiting users’ and virtualhosts’ bandwidth usage. The current versions can set virtualhosts’ and users’ bandwidth quotas, maximal download speed (like in mod_bandwidth), requests-per-second speed and the maximal number of simultanous IP connections (like in mod_limitipconn)

I recommend you to install this module into your server if your site providing download or stream service. Benefit after installing this module is: justice for all. For you as server owner: you can control the bandwidth usage and limiting your user’s download/stream speed, keep your server’s memory usage in control. For users: high availability server, no users dominate the bandwidth alone.

OK, let’s start:
install needed package (you need to compile mod_cband by yourself)

apt-get install apache2-prefork-dev make

download and extract mod_cband

tar xzf mod-cband-

EDIT: it seems that site is not hosting mod-cband anymore, you can download mod-cband form my site instead:

go inside mod-cband directory and do ./configure

cd mod-cband-

fixing Makefile; without doing this trick, you will get error message when trying to restart Apache2 afterwards. This is the error messages:

apache2: Syntax error on line 203 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/cband.load: Cannot load /usr/lib/apache2/modules/ into server: /usr/lib/apache2/modules/ undefined symbol: truncf
Action ‘configtest’ failed.
The Apache error log may have more information.

edit Makefile produced by ./configure before. add “-lm ” after “APXS_OPTS=” and before “-Wc” on line 12. See screenshot:

cband Makefile

Watch for line #12

save it and then do “make&&make install

make&&make install

restart apache2

service apache2 restart

This isn’t enough. Now, configure your virtual host to use mod_cband. This just example virtual host configuration that I use:



	DocumentRoot /var/www/mp32u

	ErrorLog ${APACHE_LOG_DIR}/mp32u.error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/mp32u.access.log combined

	CBandRemoteSpeed 102400kb/s 4 5   # speed limit, number of request per second and max. number of connections
		SetHandler cband-status  # whenever is accessed, bandwidth statistics will be shown

For more extensive and descriptive options, head to mod_cband documentation page

Example result:

Debian 6 apps/tools that I installed after fresh OS install (for server purpose)

Another personal notes for me. These are all small applications/tools that I should install after fresh OS install, most of them are tools to monitor server performance.
nmap : check sever’s open TCP/IP ports. For security reason.
nmap result
mc: a better text based file manager with 2 panes and also provide a good text editor (mcedit)
htop: a better view of top command
htop result
iftop: watch your detailed network traffic at certain ethernet device; see who’s the fastest bandwidth eater.
iftop result
bwm-ng: also bandwidth monitoring but only show overview for each ethernet
bwm-ng result
libwww-perl : this one is dependency for CSF firewall
links: text based browser
curl: this one is used later in most of my PHP scripts

apt-get install nmap htop iftop bwm-ng mc libwww-perl links curl

Personal Notes: Debian 6 additional repositories

This is personal note for myself. All of my servers I bought is self-managed and most of them is Debian 6 (squezee). I need to add additional repositories beside the default ones.

Additional Debian 6 repositories added:

  • dotdeb repository –> for latest PHP and MySQL packages
  • debian-multmedia repository  –> for latest multimedia packages such as ffmpeg, mencoder, mplayer
  • debian-backports  –> additional software from Debian previous version that not included in main repository

Full /etc/apt/sources.list

deb squeeze main
deb squeeze/updates main

# squeeze-updates, previously known as 'volatile'
deb squeeze-updates main
deb-src squeeze-updates main

deb stable all
deb-src stable all

#debian multimedia
deb stable main
deb-src stable main

#debian backports
deb squeeze-backports main

Additional steps for dotdeb repository: before doing “apt-get update“, must download and install dotdeb key first

cat dotdeb.gpg | apt-key add -

Additional steps for debian-multimedia repository: must install debian-multimedia-keyring after apt-get update

apt-get install debian-multimedia-keyring


Pinballpublishernetwork review

What/who is
They are advertising company. They provide pay-per-install advertising, means: you got money when visitors install applications/toolbar from They also had referral program. Publisher (us) can promote Pinbalpublishernetwork’s applications via banner, text link, interstitial or pop-over.

What kind of applications that they offer?
Free applications, games, smileys content program

Publisher can choose which to promote


Do they pay? payment proof?
Yes, they absolutely pay. Payment term: NET30 (just like Adsense). I already paid twice via Paypal (forgot to say: you can either paid via Paypal or check/wire). Here’s my paypal screenshot: payment proof #1

First payment from payment proof #2

Second payment from

I would say that: is suitable if your site content are one of these: download-related, free-online game and software-related tutorial (including PC desktop modification/tips/trick)

Do you still use it?
No. Why? See my report from dashboard:

pinballpublishernetwork reports

My payment schedule report

Look closely and compare it to my paypal payment proof. First payment should be sent at November 11th but they send me payment at November 23rd; I said: Okay, a little 12 days late is rather fine.
Now look at the second payment schedule and compare it to my second paypal payment proof. I should been paid at Nov 29th but they sent the payment at January 13th 2012. That’s almost 2 months late. In the middle of the payment delay, my account manager had been replaced, I had to re-send my W8-BEN form and do some back-and-fort email communications with my account manager more than 10 times. Crazy! I think maybe they were a runner at that time.
So, that’s my simple reason for removing their ads code from my site. If they pay on-time, I would love to continue to use them.

Final words: you should try them!

Achieving what W3 Total Cache does for your non-WordPress site

Before implementing this tips, your server/web host had to use Apache and activated all modules needed as I already posted.
W3 Total Cached had a good .htacess settings that will made your site/blog score higher in Google Page Speed and YSlow. I noticed that these .htaccess settings is quite generic and can be implemented in non-blog, non-Wordpress site.
Here’s the .htaccess settings that you need to copy and paste to your site’s .htaccess:

Options +FollowSymLinks

    AddType text/css .css
    AddType application/x-javascript .js
    AddType text/x-component .htc
    AddType text/html .html .htm
    AddType text/richtext .rtf .rtx
    AddType image/svg+xml .svg .svgz
    AddType text/plain .txt
    AddType text/xsd .xsd
    AddType text/xsl .xsl
    AddType text/xml .xml
    AddType video/asf .asf .asx .wax .wmv .wmx
    AddType video/avi .avi
    AddType image/bmp .bmp
    AddType application/java .class
    AddType video/divx .divx
    AddType application/msword .doc .docx
    AddType application/ .eot
    AddType application/x-msdownload .exe
    AddType image/gif .gif
    AddType application/x-gzip .gz .gzip
    AddType image/x-icon .ico
    AddType image/jpeg .jpg .jpeg .jpe
    AddType application/ .mdb
    AddType audio/midi .mid .midi
    AddType video/quicktime .mov .qt
    AddType audio/mpeg .mp3 .m4a
    AddType video/mp4 .mp4 .m4v
    AddType video/mpeg .mpeg .mpg .mpe
    AddType application/ .mpp
    AddType application/x-font-otf .otf
    AddType application/vnd.oasis.opendocument.database .odb
    AddType application/vnd.oasis.opendocument.chart .odc
    AddType application/vnd.oasis.opendocument.formula .odf
    AddType application/ .odg
    AddType application/vnd.oasis.opendocument.presentation .odp
    AddType application/vnd.oasis.opendocument.spreadsheet .ods
    AddType application/vnd.oasis.opendocument.text .odt
    AddType audio/ogg .ogg
    AddType application/pdf .pdf
    AddType image/png .png
    AddType application/ .pot .pps .ppt .pptx
    AddType audio/x-realaudio .ra .ram
    AddType application/x-shockwave-flash .swf
    AddType application/x-tar .tar
    AddType image/tiff .tif .tiff
    AddType application/x-font-ttf .ttf .ttc
    AddType audio/wav .wav
    AddType audio/wma .wma
    AddType application/ .wri
    AddType application/ .xla .xls .xlsx .xlt .xlw
    AddType application/zip .zip

    ExpiresActive On
    ExpiresByType text/css A31536000
    ExpiresByType application/x-javascript A31536000
    ExpiresByType text/x-component A31536000
    ExpiresByType text/html A3600
    ExpiresByType text/richtext A3600
    ExpiresByType image/svg+xml A3600
    ExpiresByType text/plain A3600
    ExpiresByType text/xsd A3600
    ExpiresByType text/xsl A3600
    ExpiresByType text/xml A3600
    ExpiresByType video/asf A31536000
    ExpiresByType video/avi A31536000
    ExpiresByType image/bmp A31536000
    ExpiresByType application/java A31536000
    ExpiresByType video/divx A31536000
    ExpiresByType application/msword A31536000
    ExpiresByType application/ A31536000
    ExpiresByType application/x-msdownload A31536000
    ExpiresByType image/gif A31536000
    ExpiresByType application/x-gzip A31536000
    ExpiresByType image/x-icon A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType application/ A31536000
    ExpiresByType audio/midi A31536000
    ExpiresByType video/quicktime A31536000
    ExpiresByType audio/mpeg A31536000
    ExpiresByType video/mp4 A31536000
    ExpiresByType video/mpeg A31536000
    ExpiresByType application/ A31536000
    ExpiresByType application/x-font-otf A31536000
    ExpiresByType application/vnd.oasis.opendocument.database A31536000
    ExpiresByType application/vnd.oasis.opendocument.chart A31536000
    ExpiresByType application/vnd.oasis.opendocument.formula A31536000
    ExpiresByType application/ A31536000
    ExpiresByType application/vnd.oasis.opendocument.presentation A31536000
    ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000
    ExpiresByType application/vnd.oasis.opendocument.text A31536000
    ExpiresByType audio/ogg A31536000
    ExpiresByType application/pdf A31536000
    ExpiresByType image/png A31536000
    ExpiresByType application/ A31536000
    ExpiresByType audio/x-realaudio A31536000
    ExpiresByType image/svg+xml A31536000
    ExpiresByType application/x-shockwave-flash A31536000
    ExpiresByType application/x-tar A31536000
    ExpiresByType image/tiff A31536000
    ExpiresByType application/x-font-ttf A31536000
    ExpiresByType audio/wav A31536000
    ExpiresByType audio/wma A31536000
    ExpiresByType application/ A31536000
    ExpiresByType application/ A31536000
    ExpiresByType application/zip A31536000

        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
        Header append Vary User-Agent env=!dont-vary
        AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon

        Header set Pragma "public"
        Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    FileETag MTime Size

        Header set Pragma "public"
        Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    FileETag MTime Size

        Header set Pragma "public"
        Header append Cache-Control "public, must-revalidate, proxy-revalidate"
    FileETag MTime Size

What it does?

  • enabling gzip compression, your site’s HTML codes will be compressed on-the-fly before served to users/visitors
  • minifying CSS, JS and HTML files from your site
  • add expiry header to your files based on file types
  • set ETag value
  • Specify a Vary: Accept-Encoding header

I’ve implemented this on, the result is as expected.