1

Server Information as follows

  • Plesk Control Panel
  • CentOS 7 Operating System
  • Nginx Proxy running on port 80
  • Apache running on port 7080
  • Magento Website
  • Elastic Search
  • Redis Cache
  • CSF Firewall

I installed varnish via Docker with the following configuration. Followed the link here

enter image description here

Whenever I add Docker Proxy Rule the website breaks out ending up with the following error:

Error 503 Backend fetch failed
Backend fetch failed

Guru Meditation:
XID: 65824

Varnish cache server

1 Answer 1

0

Varnish uses /etc/varnish/default.vcl as the location of its VCL configuration. In this configuration you'll find a backend definition along with a set of caching policies.

The default backend has the following configuration:

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

This configuration assumes that the backend runs locally on port 8080.

In a Docker context that's not realistic because every service runs in its own container. That's why you need to modify your VCL file.

The best way to do this is by leveraging Volume mapping, which is also part of the screenshot you attached.

Make sure there's a VCL file on the host system and mount it into /etc/varnish/default.vcl of your Varnish container.

The .host and .port attributes should refer to the system you're trying to proxy to.

That will allow Varnish to connect to the right system and cache the HTTP responses.

If you still have the same error after adjusting, please have a look at the following tutorial: https://www.varnish-software.com/developers/tutorials/troubleshooting-varnish/#backend-errors . This will help you debug backend errors using a varnishlog command.

Side note: even if you can properly connect to a backend, there's no guarantee that Varnish will cache HTTP responses. Varnish has a built-in VCL behavior that describes what can be cached and what cannot be cached. See https://www.varnish-software.com/developers/tutorials/varnish-builtin-vcl/ for a tutorial on built-in VCL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.