Realizing vhosts with varnish

Michael Alger varnish at
Thu Dec 16 10:44:24 CET 2010

On Thu, Dec 16, 2010 at 10:06:04AM +0100, Frank Helmschrott wrote:
> I currently have a default.vcl containing these lines:
> sub vcl_recv {
>         if (req.http.Host = "")

Is this verbatim? Should be == for comparison; with just an = you'll get
an error:

Message from VCC-compiler:
Invalid condition '=' on IP number variable
  only '==', '!=' and '~' are legal
(/etc/varnish/inc-serverips.vcl Line 2 Pos 15)
if (server.ip = "")
Running VCC-compiler failed, exit 1
VCL compilation failed

> The two vhost files contain a basically working configuration (it
> workes well when using it as the only config). With the default.vcl
> from above varnish doesn't start. Unfortunately on my server (using
> CentOS 5.5 and varnish from EPL) i don't get any error messages what
> may be wrong. Is there something missing that must be set before this
> if/else statement can be handled?

You can look in /var/log/syslog or similar to see if you get errors
logged there. Alternatively, you can use the command-line interface to
issue the reload command.

# varnishadm -S /etc/varnish/secret -T :6082

vcl.load newconfig /etc/varnish/default.vcl

<if that works>

vcl.use newconfig

> One additional question: When fetching the files from backend servers,
> doesn't varnish send a hostname? I tried putting some more vhosts on
> one IP on the backend and setup this IP in varnish as backend server
> but what varnish delivered was the default content from the backend
> instead of the vhosts content the hostname belonged to.

It'll send whatever hostname is set in the request, i.e. req.http.Host.
At least, it should. You are stripping the "www." from the front - is
the backend expecting that and configured to accept that?

More information about the varnish-misc mailing list