Boost module and rsync'ed apache 'mirrors'
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
[example-cache]
comment = Example static html files
path = /var/www/example.com/drupal-5/cache/example.com
read only = yes
list = no
uid = nobody
gid = nogroup
[example-files]
comment = Example files
path = /var/www/example.com/drupal-5.5/files/example.com
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://drupal.server.example.com/example-cache /var/www/example.mirror/cache/example.com//usr/bin/rsync -avz --delete rsync://drupal.server.example.com/example-files /var/www/html/example.mirror/files/example.com
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/example.com/>
AllowOverride all
</Directory>ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>ProxyPass /index.php http://drupal.server.example.com/index.phpProxyPassReverse /index.php http://drupal.server.example.com/index.php
And it works!