Varnish logs twice

The default configuration of varnish logs every request twice, once for the client and once for the backend communication

edit the line in /etc/init.d/varnishncsa to something like

DAEMON_OPTS="-c -a -w $logfile -D -P $pidfile"

from the varnishncsa man page

-c Include log entries which result from communication with a client. If neither -b nor -c is specified, varnishncsa acts as if they both were.

Read more

Varnish ACL

To setup an IP based access control list so that only allowed users may access the site.

sub vcl_recv {

  if (!(client.ip ~ testers)) {
    error 403 "Access Denied - server in test mode (IP not in ACL)";
  }

}

acl testers {
    "localhost";
    "www.example.com";
    "192.168.0.1";
}

In my case I need to be able to test a dev site but don't want to make it public, we tried using password authentication but that made it harder to test varnish as the authentication headers affected caching.

Read more

Ubuntu on a Samsung N150 netbook

Installing Ubuntu on a new netbook proved remarkably easy once I got past a couple of hurdles

Read more

Varnish caching - passing a hostname

I'm using varnish to cache a REST service that's slow enough to cause me grief in development.

Out of the box it assumes you are caching your own server and that the client is already using the right host header.

To specify that it should use a host header to match the backend I'm using a config like

backend default {
        set backend.host = "www.example.com";
        set backend.port = "80";

}


sub vcl_recv {
        set req.http.host = "www.example.com";
}

Read more

Resizing an ext3 filesystem on LVM

When I installed my system I wasn't quite happy with the way the installer divided my hard disk - but at the time I was in a hurry...

I have since found that repeated loading of databases during development used up all available space in /var and debug files were filling /tmp

So I had to figure out how to resize them.

 

Thanks to 

http://blog.dhampir.no/content/resizing-an-ext3-filesystem-on-an-lvm

Read more

ssh port forwarding

Every now and again I find I have ssh access to one server - which has access to somewhere I need to get to - but I want direct access (eg to forward an X session)

ssh -L 2222:otherserver:22 server

ssh -X -p 2222 localhost

an now I'm logged into othersever with forwarded X

Read more

Drush "tput: No value for $TERM and no -T specified"

The drush script which provides comman line acceess to drupal functionality emits an error message when run as a cron job

tput: No value for $TERM and no -T specified

# If it is not exported determine and export the number of columns.
if [ -z $COLUMNS ]; then
  export COLUMNS=$(tput cols)
fi

I presume drush uses this information to calculate layout of output.

However when running as a cron job COLUMNS is not set and tput gives the above error.

Read more

Upgrading Debian Etch to Lenny

Debian Etch has been serving me well for a few years with wonderfully easy and infrequent maintenance.

However it's at the end of its life

http://www.debian.org/News/2010/20100121

So I've upgraded to Lenny following these instructions

http://www.debian.org/releases/lenny/i386/release-notes/ch-upgrading.en....

It was remarkably painless

One small problem with the mail system.

Errors were encountered while processing:
exim4-config
imapproxy
exim4-base
exim4-daemon-light
courier-imap
at
bsd-mailx
courier-imap-ssl
mailx

Read more

Amazon MP3 Downloads for Linux

It's great that Amazon actually offer a version of thier MP3 downloader for Linux - just a shame that it doesn't work for many distributions.

Fortunately clamz is available 

It's a great little command line utility with a very forgetable name.

Read more

Hard Drive Testing using smartmontools

Test the hard drive with

smartctl -t long /dev/hd?

This may take hours to run and will do so as a background process.

Once complete run the following to see results

smartctl -l selftest /dev/hd?

Read more