与Apache域清漆configuration

我在Debian上安装了varnish。

我在http://example.com上有一个在Apache上运行的网站

这是我的/etc/varnish/default

 vcl 4.0; backend default { .host = "example.com"; .port = "8080"; } 

清漆开始,我可以看到网站的内容在http://127.0.0.1:6081/

响应标题:

 Pragma: no-cache Date: Tue, 25 Aug 2015 12:29:38 GMT Content-Encoding: gzip Server: Apache/2.4.10 (Ubuntu) Age: 0 X-Powered-By: PHP/5.6.4-4ubuntu6.2 Vary: Accept-Encoding Content-Type: text/html; charset=UTF-8 Via: 1.1 varnish-v4 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 X-Varnish: 229436 Connection: keep-alive Accept-Ranges: bytes Content-Length: 23044 Expires: Thu, 19 Nov 1981 08:52:00 GMT 200 OK 

如何在http://example.com下面显示此内容? 如何configurationVarnish和Apache vhost?

在/ etc / hosts文件中,在127.0.0.1 IP上添加example.com和任何其他虚拟主机名称。 当清漆访问“example.com”时,它将被parsing为127.0.0.1,但是正确的主机名头将跟随对apache的请求,反过来它将能够将其映射到正确的虚拟主机。 在apache和varnish中都不需要特殊的configuration,只需要在apache中configurationvhost就可以了。