Tutorial: compilation fails

976 views Asked by At

Ubuntu 16.04.2

varnish-4.1.1

I stuck here: https://varnish-cache.org/docs/4.1/tutorial/starting_varnish.html

The very first change in configuration in the whole book. It said: change host to www.varnish-cache.org and reload.

/etc/varnish/default.vcl

vcl 4.0;

backend default {
    .host = "www.varnish-cache.org";
    .port = "80";
}

I executed:

sudo service varnish restart

sudo service varnish reload

But anyway I constantly have "Error 503 Backend fetch failed".

I have tried:

$ sudo varnishd -d -f default.vcl 
Error:
Failed to create vcl_boot/vgc.so: Permission deniedVCL compilation failed

It seems that compilation fails. Could you help me here?

1

There are 1 answers

3
Danila Vershinin On

It's a somewhat broken tutorial for a few reasons:

  • They ask you to point backend to a DNS name. The proper way is to specify IP in backend definitions
  • Whatever you specify (DNS or IP) it will end up passing Host header of the site you access Varnish with and ask backend server to deliver site with that hostname.

So why you're getting an error as per tutorial:

  • You access, e.g. http://localhost/ (or whatever hostname you access your Varnish with)
  • Then Varnish talks to HTTP server at varnish-cache.org and asks for http://localhost.
  • Obviously the varnish-cache.org server has no idea about that one and most likely (as per their configuration will issue a redirect / error / etc.) thus the error that you see.

It is best to point it to your own web server instead and do it like this:

vcl 4.0;

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

The above assumes that you run a web server (nginx or Apache, etc.) at the same machine with Varnish and you made it run at port 8080.