Valentin Bora

My relationship with the web exposed

Parallels Plesk Panel and Varnish working together on CentOS 5

The big problem with Plesk Panel is that you can have a hard time working around it and changing its defaults.

In my case I wanted to configure Apache to listen on a different port than the default 80, in order to put Varnish in front of it. If you change it manually in the vhost config files and httpd.conf (talking here in particular about CentOS) it might work for a while but next time you make a change in the Plesk Panel everything is going to come back to default.

Changing default Apache port with Plesk Panel

The solution is to run the following command:

/usr/local/psa/admin/sbin/websrvmng --set-http-port --port=8080
/usr/local/psa/admin/sbin/websrvmng --reconfigure-all

This changes the default http port that Plesk is going to use for HTTP vhosts and then reconfigure-all is going to rewrite the whole set of config files.

Installing Varnish

Please refer to http://blog.quilitz.de/2010/02/varnish-on-centos/ or other articles that you can find on Google, this one should be easy using yum.

Moving Varnish to port 80

On CentOS, you have to reconfigure Varnish to listen on port 80. This can be done in /etc/sysconfig/varnish. Look for DAEMON_OPTS and change it to look like the following:

DAEMON_OPTS="-a :80 \
           -T localhost:6082 \
           -f /etc/varnish/default.vcl \
           -s file,/var/lib/varnish/varnish_storage.bin,1G"

On Ubuntu, this can be done in /etc/default/varnish

Very very basic Varnish configuration

Please first make a backup of /etc/varnish/default.vcl so that you can come back to it whenever necessary. This is how it should look like for you:

backend default {
   .host = "127.0.0.1";
  .port = "8080";
}

This entry was written by Valentin, posted on March 11, 2011 at 1:34 pm, filed under Server administration and tagged , , , . Leave a comment or view the discussion at the permalink.