Boost module and rsync'ed apache 'mirrors'

by ekes

OK, I'm not sure if you actually want to do this, but I thought I would try to see if you can do it. Setting up the Boost module to create static html pages of anonymous Drupal page views, then serving them from a completely different machine. It's kind of nice to have a way of having a bit of a static 'mirror' for your content, but I'm guessing squid is better at all this.

So how?

First of all set up Boost on the Drupal site. It was completely straightforward - just follow the readme.txt. Running on default settings it is generating .html files and sym-links in the cache directory. These will be transfered, along with the files directory, regularly using rsync.

Rsync is configured in /etc/rsync.conf:

  max connections = 2
  log file = /var/log/rsync.log
  timeout = 300
  comment = Example static html files
  path = /var/www/
  read only = yes
  list = no
  uid = nobody
  gid = nogroup

  comment = Example files
  path = /var/www/
  read only = yes
  list = no
  uid = nobody
  gid = nogroup

The other static files that want to be served are all the .css, misc images and such like. I rolled these up in a tarball - in the DocumentRoot:

find . -regex '.*\(\.js\|\.css\|\.gif\|\.png\)' | xargs tar -zcvf static_files.tar.gz

Next over to the 'mirror'. First I copied the tarball and unpacked it in the 'mirrors' document root. I also copied over the boost .htaccess file and put this there too.

Then rsync'ed the cache and files directories:

/usr/bin/rsync -avz --delete rsync:// /var/www/example.mirror/cache/
/usr/bin/rsync -avz --delete rsync:// /var/www/html/example.mirror/files/

As this worked, swapping v for q (verbose for quiet) they were put in crontab to run regularly.

Finally setting up a standard vhost, that will serve the static content if it has it and the user is anonymous, or proxy to the server if not. The boost .htaccess file works for finding the static content if it's there, and overrides the vhost, so just this was added for other content:

<Directory /var/www/>
    AllowOverride all

ProxyRequests Off

<Proxy *>
  Order deny,allow
  Allow from all

ProxyPass /index.php
ProxyPassReverse /index.php

And it works!