How to set up varnish on different server?

笑着哭i 提交于 2019-12-11 21:01:11

问题


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.


回答1:


You just specify within your

backend .. {

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




回答2:


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;
}


来源:https://stackoverflow.com/questions/25843279/how-to-set-up-varnish-on-different-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!