如何修复:Varnish无法在Apache上启用

时间:2019-06-12 13:04:41

标签: apache varnish varnish-vcl

新服务器设置,但在安装后测试Varnish不会显示预期结果。看起来Varnish没有为Apache正确配置。

服务器是CentOS 7,运行Apache 2.4,Redis,RabbitMQ和Varnish 5.2。

我已按照说明将Varnish侦听端口更改为80,并将后端默认值更改为declare nlist NumberList := NumberList(1,2,3,4,5,6,7,8,9,10); n_first pls_integer := 1; n_last pls_integer := 10; nlist2 NumberList begin select * bulk collect into nlist2 from ( select column_value from table(nlist) order by 1 desc ); end; 中的.port ="8080"/etc/varnish/default.vcl中的VARNISH_LISTEN_PORT=80

/etc/varnish/varnish.params

当我重新启动Varnish和Apache并运行命令时 curl-我http://localhost 我得到以下结果:

backend default {
    .host = "164.160.89.188";
    .port = "8080";
}

我应该得到这样的东西

HTTP/1.1 200 OK
Date: Wed, 12 Jun 2019 12:45:59 GMT
Last-Modified: Wed, 30 Jan 2019 02:03:25 GMT
Content-Type: text/html
Vary: Accept-Encoding
Pragma: no-cache
Expires: -1
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Accept-Ranges: bytes
Connection: keep-alive

“清漆状态”显示以下内容

X-Varnish: 13
Age: 0
Via: 1.1 varnish-v5

1 个答案:

答案 0 :(得分:0)

似乎Apache发送了Pragma头,快速的解决方法是在vcl_backend_response中写入“ unset beresp.http.Pragma”,它将取消pragma头并开始缓存内容,但是您可能要检查Apache为什么发送头