How to set up varnish on different server?

2019-09-15 23:13发布

I'd like to know how to use varnish to cache website that is in different server?

I have my website that uses Magento CE, I have already installed turpentine extension and I have different dedicated server. I successfully installed varnish on dedicated server, how to configure varnish to tell that I need to cache website that's in different server, where should insert server ip, I only found varnish tutorials where it's installed in the same server.

2条回答
啃猪蹄的小仙女
2楼-- · 2019-09-15 23:48

Just create a backend that points at your webservers ip or domainname. Here a example with provided healtcheck.

probe healthcheck_webserver {
    .url = "/";
    .interval = 5s;
    .timeout = 1s;
    .window = 5;
    .threshold = 3;
    .expected_response = 200;
}

backend webserver {
   .host = "xxx.xxx.xxx.xxx";
   .port = "THEPORTTHATAPACHELISTENSTO";
   .probe =  healthcheck_webserver;
}

And ofcourse dont forget to use this backend in sub vcl_recv:

if (req.http.host ~ "yourdomain.com") 
{
    set req.backend = webserver;
}
查看更多
We Are One
3楼-- · 2019-09-16 00:07

You just specify within your

backend .. {

section the ip address + port of your 2nd server.

查看更多
登录 后发表回答