Configure multiple sites with Varnish

前端 未结 4 1168
不知归路
不知归路 2020-12-12 09:34

We have a server which needs to serve multiple domains though varnish e.g. example1.com, example2.com and example3.com

Our current .vcl file looks like this:

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 10:14

    unable to add comment so here we go

    slight modification for varnish 4

    #for www.example.com or example.com
    if (req.http.host ~ "^(www\.)?example\.com$") {
            set req.backend_hint = example_com;
            return (lookup);
    }
    
    #with any subdomain support
    if (req.http.host ~ "^(.*\.)?example2\.com$") {
            set req.backend_hint = example2_com;
            return (lookup);
    }
    

    replace backend with backend_hint

提交回复
热议问题