The last time I wrote about CDN, I wrote about how to configure CDN for wordpress to speed up your wordpress blog to display content to users faster and more efficiently. However, a few regular readers like to know how to configure the Amazon CDN or other CDN network to use with Vbulletin forum software. In this quick tutorial, I will explains how to configure Vbulletin, Apache/Lighttpd webserver, Bind dns server to use a CDN to distribute your common files such as css, js, user uploaded files and lighten load on your web server.

Our Sample Forum Setup

  1. Forum URL : – This is hosted on your own server using Apache, Lighttpd, or Nginx.
  2. Origin Pull URL : – This is hosted on your own server. You need to configure your web server, vbulletin and dns server to use this. This is called as “Origin Pull Host” which is a CDN method by which content is pulled from your web server.
  3. CDN URL : – This is a cdn url hosted by your CDN provider such as Amazon. This url always point to an edge server via proprietary DNS hacks. must be set as CNAME records which will point to domain names of CDN server.
  4. CDN DNS CNAME : – is your CDN provider. This is must be set as CNAME for

Step # 1: Purchase CDN Service

As I said earlier the cost varies between CDN providers. Check CDN service providers website for more information. Next, you need to use service providers “control panel” to configure an “Origin Pull Host” for each domain. In other words configure in origin pull mode. The control panel will also provide your an option to setup CDN dns CNAME. You need to use same CNAME in step # 2. Once the configuration is active and the CNAME is resolving, calls to will be cached from

Step # 2: Update Your DNS Server

I’m assuming that you are using BIND dns server edit your zone file and add entry as follows (you can skip this step and use your ISP’s dns hosting providers control panel to setup CNAME and origin host):

; CDN CNAME mapping for
cdn                 3660       IN CNAME
; Your cdn-origin url (note is also hosted on same server IP
cdn-origin        3600       IN A

Save and close the file. Reload named:
# rndc reload && tail -f /var/log/messages
To keep your configuration simple use the same web server for origin pull domain and main domain i.e. host both and on same web server. This allows you to directly upload and map files to the CDN server.

Step # 3: Configure Origin Pull Web Server

You need to configure as follows:

  1. Origin pull DocumentRoot: /home/httpd/ – All your .css, .js and uploaded files are hosted here.
  2. Server Forum DocumentRoot: /home/httpd/ – All your vbulletin files are hosted here.
  3. MaxAge: Set cache-lifetime headers for static files for cdn network.
  4. Etags: An ETag (entity tag) is part of HTTP, the protocol for the World Wide Web. It is a response header that may be returned by an HTTP/1.1 compliant web server and is used to determine change in content at a given URL. When a new HTTP response contains the same ETag as an older HTTP response, the client can conclude that the content is the same without further downloading.

Sample Apache Configuration

<virtualHost >
	DocumentRoot /home/httpd/
	ErrorLog /var/logs/httpd/cdn-error_log
	CustomLog /var/logs/httpd/cdn-access_log common
	# Files in this directory will be cached for 1 week only.
	# After 1 week, CDN server will check if the contents has been modified or not.
	# If not modified, Apache will send 304 "Not Modified" header
	<directory "/userimages">
		Header set Cache-Control "max-age=604800, must-revalidate"
	# Disable ETag as we are on cluster Apache server
	<directory "/pdfs">
		Header unset ETag
		FileETag None
	# Do not cache
	<directory "/patches">
		Header Set Cache-Control "max-age=0, no-store"

Sample Lighttpd Configuration

# Configure ETags
etag.use-inode = "enable"
etag.use-mtime = "enable"
etag.use-size = "enable"
static-file.etags = "enable"
###### CDN FILES via Wordpress Upload ##############
$HTTP["host"]  == ""{
        server.document-root = "/home/httpd/"
        accesslog.filename         = "/var/log/lighttpd/cdn.access.log"
	#  Set max age
        $HTTP["url"] =~ "^/" {
            expire.url = ( "" => "access 60 days" )

Adjust documentroot as per your setup.

Step # 4: Create Required Directories

You need to configure files for
# mkdir -p /home/httpd/
# cd /home/httpd/

Next, soft link your .css, .js, images, clientscripts files against original forum documentroot (i.e. /home/httpd/ as follows:
# ln -s ../ .
# ln -s ../ .
# ln -s ../ .
# ln -s ../ .
# ln -s ../ .
# ln -s ../ .

Again, feel free to adjust paths according to your setup. Test your new cdn urls:

Step # 5: Configure Vbulletin To Use a CDN Server

You need to edit your vbulletin style. Open admincp by visiting > Select Styles & Templates > Replacement Variable Manager:

Fig.01: Vbulletin Editing Styles And Templates

Fig.01: Vbulletin Editing Styles And Templates

Click on [Add New Replacement Variable] link and set it as follows:

  • Set Search for Text to href=”clientscript
  • Set Replace with Text to href=”

Sample outputs:

Fig.02: Vbulletin Adding Replacement Variable For CDN

Fig.02: Vbulletin Adding Replacement Variable For CDN

You need to repeat this step for images, javascript and other shared media as follows:

Search for Text Replace with Text
src=”clear.gif” src=””
src=”customavatars/ src=”
src=”customprofilepics/ src=”
src=”images/ src=”
url(“clientscript url(“
src=”clientscript/ src=”
href=”clientscript/ href=”
url(./images/ url(
url(images/ url(
var imgdir_misc = “images/misc”; var IMGDIR_MISC = “”;

Avatars & Pictures – Storage Type

Visit Avatars > Storage Type and set them as follows to match your above CDN rules by moving all of them to file systems:

  • Avatars are currently being served from the filesystem at ./customavatars
  • Profile pictures are currently being served from the filesystem at ./customprofilepics
  • Signature pictures are currently being served from the filesystem at ./signaturepics

How Do I Test Images And Other Media Files Are Cached Or Not By CDN?

Use curl to test HTTP headers (look for Etags, max-age and Expires headers):
$ curl -I ''
$ curl -I


The forum home page loading (rendering) time went from 8.5 seconds to 2.2 seconds and average thread loading time went from 14.3 seconds to 5 seconds:

Fig.03 Speed Improvements With CDN

Fig.03 Speed Improvements With CDN

See 6 tools to test web site speed for more information.

Recommend readings:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 25 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
25 comments… add one
  • Joe Jun 11, 2010 @ 20:53

    Thanks Vivek!

    Finally, my wish came true πŸ™‚

    • trman Mar 22, 2011 @ 18:57

      Many thanks for this! I used it yesterday to set up my Vbulletin and it worked great.

      I had one question, and that is the purpose of the Sim Links? I was thinking they were in case the CDN goes down that the images/javascript etc would still load from the subdomain, is this correct? I really don’t see any other purpose for them.

      Thanks again!

  • Philippe Petrinko Jun 13, 2010 @ 9:47

    Many thanks Vivek,

    I found your article interesting, and well-done.
    Your work do cover a very broad spectrum of IT!
    Keep up the good work, man. πŸ™‚

    — Philippe

  • 🐧 nixCraft Jun 13, 2010 @ 10:19

    @Joe / @Philippe,, You are welcome! πŸ™‚

  • Vamsi Jun 14, 2010 @ 6:22

    Thank you very much for the lighty config ..

    • 🐧 nixCraft Jun 15, 2010 @ 6:53

      No problem! I hope you use it on your forum.

  • Car Forum Jun 16, 2010 @ 22:54

    Worked like a charm with Amazon CloudFront.

  • Win Jun 17, 2010 @ 7:16

    Great article!

    Is there much benefit of using a CDN if most of your visitors are from the same country that your server resides in?

    I imagine though that the CDN will provide improved page load speeds due to parallel downloading and improved management of cached content?

    • 🐧 nixCraft Jun 17, 2010 @ 7:21

      It ALL depends upon your cdn providers network. Some large CDN providers have multiple edge servers in same country. For example, large provider such as Akamai does provide multiple edge servers so you end up speeding up website. However, some provider only got 1 edge server. So you need to do your own research before purchasing such CDN.


  • Win Jun 17, 2010 @ 11:15

    Cheers Vivek, thanks for that.

  • LH Jun 29, 2010 @ 23:12


    What if I’d like to accelerate entire website app written in php or perl. Can I use CDN for caching pages generated on fly using php?


    • 🐧 nixCraft Jun 30, 2010 @ 21:12

      There are different types of CDN. The CDN discussed in this article is for caching static files. You need to use “Dynamic Content Acceleration” with SSL (optional for securing data transfer). Checkout the list posted at wordpress CDN article, and most large CDN provider also provides Dynamic Content Acceleration.


  • Alex Jul 13, 2010 @ 11:12

    Hello, I tried to use your settings but it doesn’t works well. I use vBulletin 4.0.3, Can you tell if the tutorial is compatible also with my version?

    Thank you

    • 🐧 nixCraft Jul 14, 2010 @ 5:39

      I’ve not tested this with VB 4.x. So I cannot comment out. This is only tested on v3.x.

  • yayabaobao Jul 14, 2010 @ 5:30

    Great article!

  • John Jul 14, 2010 @ 6:26

    Thanks for posting this guide.

    I’m not sure, but I may have found a small mistake. In your first replacement variable example, shouldn’t the following:


    instead be:



    • 🐧 nixCraft Jul 14, 2010 @ 11:17

      Actually both src=clientscript and href=clientscript exitst. So no it wasn’t a typo on my part.


  • HarlAcicich Oct 22, 2010 @ 1:15

    hell yea.thanx for sharing this post with me.i just found it buy google couse i was searching for
    more info about this.Ang WOOHOO! i found your post that was so usefull for me πŸ™‚
    feel free to drop me email i will send small donation! love for all you here.

  • mantomarantina Nov 3, 2010 @ 22:18


    it’s my first topic here
    i hope to be happy with you

    thank you

  • Kevin Dec 7, 2010 @ 0:07

    Vivek, great article. We put together a similar write-up but I appreciate how detailed yours is. Our CDN (with 10 PoPs) integrates well with vbulletin, and you can read more about it, here:

    Feel free to contact me directly if anyone has any questions.

  • trman Mar 28, 2011 @ 17:55

    (oops I replied to another post by mistake instead of leaving a new comment, sorry)

    Many thanks for this! I used it to set up my Vbulletin and it worked great.

    I had one question, and that is the purpose of the Sim Links? I was thinking they were in case the CDN goes down that the images/javascript etc would still load from the subdomain, is this correct? I really donÒ€ℒt see any other purpose for them.

    Thanks again!

  • satla Apr 28, 2012 @ 13:14

    I am stuck on this step:
    # ln -s ../ .
    # ln -s ../ .
    # ln -s ../ .
    # ln -s ../ .
    # ln -s ../ .
    # ln -s ../ .

    I tried to create soft link but it doesn’t work
    it doesn’t create a link, just a custom file.

    Can you help?

    • 🐧 nixCraft Apr 29, 2012 @ 16:23

      Do see any specific error on the screen?

  • Bnay Dec 1, 2012 @ 20:30

    Hi Vivek,

    It worked… however partially. I have some other folders such as xyz under images folder. But they are not getting redirected to CDN.

    for eg: contents of images/xyz are not getting redirected.

    however, contents of images/providers are getting redirected..

    any idea ???

  • Nick Jul 31, 2013 @ 0:14


    The directions above worked for me but I’m having trouble adding more paths to the CDN. For example I would like to include /attachments and /arcade. I tried following the other examples as a guide but looking at the page src and hovering over pieces of my thread pages they don’t appear to be loaded via the CDN like /clientscript and /images. Is it possible to CDN more parts of my vBulletin?

    Thank you, -Nick

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum