我有一个VPS服务2个WordPress的安装。 使用清漆> Nginx> PHP-FPM现在我在nginx的conf.d文件夹中有这个:
domain1.com.conf domain2.com.conf
一个域的configuration示例如下所示:
server { server_name domain1.com www.domain1.com *.domain1.com; listen 127.0.0.1:81; expires max; root /home/domain1.com; index index.php;
Varnish的默认VCL文件:
backend default { .host = "127.0.0.1"; .port = "81"; .connect_timeout = 600s; .first_byte_timeout = 600s; .between_bytes_timeout = 600s; }
所有的域都有相同的监听值,127.0.0.1:81。
如何使Varnish实际提供正确的域的caching版本?
按域名拆分caching,用next更改你的VCLconfiguration:把这个添加到vcl_hash子例程中:
清漆2.1.x
if (req.http.host) { set req.hash += req.http.host; } else { set req.hash += server.ip; }
清漆3.x
if (req.http.host) { hash_data(req.http.host); } else { hash_data(server.ip); }