我在同一台服务器上的Varnish(4.1.0)前面有Nginx(1.9.9)。
//nginx upstream varnish { server 127.0.0.1:8391; keepalive 16; } location ~ \.php$ { proxy_pass http://varnish; proxy_http_version 1.1; #for 1.0 varnish shows blank page proxy_set_header Connection ""; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 600; proxy_send_timeout 600; proxy_connect_timeout 600; } //varnish DAEMON_OPTS="-a :8391 \ -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -s malloc,1024m"
对于0.001%的请求,nginx显示错误:
[error] 5331#5331: *7392847 upstream prematurely closed connection while reading response header from upstream, client: xx.xx.xx.xx, server: _, request: "GET /home HTTP/1.1", upstream: "http://127.0.0.1:8391/index.php?q=/home", host: "xxx", referrer: "xxx"
玩proxy_buffers没有帮助。
我们有这个相同的问题,使用Nginx的SSL和HTTP2,Varnishcaching和Apache的实际Web服务。
我注意到这只发生在我们已经设置绕过清漆的请求上。 出于某种原因,多年前,我们在我们的VCL文件中使用了return(pipe)。 我把它从return(pipe)改成return(pass),并且voilà,问题解决了。
显然,你需要看看你的VCL,并确保返回(传递)适用于你的场景,但是在大多数情况下,它可能是答案。