<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><font size="2">Hello,<br><br>I have a wired problem with varnish, i get "Error 503 Service Unavailable / Service Unavailable / Guru Meditation". This is not happening all the time! If i restart varnishd all things are fine for random 5-10 mins.<br>I checked varnishlog and i get : "9 FetchError c no backend connection". Strange thing because my 3 nginx servers are up and running just fine, checked error log on all of them and there is no problem :|<br>I searched on google and from many results i'v read prev message from Abraham Cruz (https://www.varnish-cache.org/lists/pipermail/varnish-misc/2012-June/022127.html), i tryed to setup like he has in there but i receive same error.<br><br>So here are some pastes from varnishlog and my
vcls.<br>Please let me know if i have some config erorr or something, i can't figure out what is wrong in here and why i get this.<br><br>I'm using Varnish 3.0.0~beta1-1~squeeze2 on Debian 6 machine.<br><br># ---- start varnishlog<br>9 SessionOpen c xxx.xxx.xxx.xxx 49940 website.com:80<br> 9 ReqStart c xxx.xxx.xxx.xxx 49940 905690731<br> 9 RxRequest c GET<br> 9 RxURL c /auth/login<br> 9 RxProtocol c HTTP/1.1<br> 9 RxHeader c Host: website.com<br> 9 RxHeader c User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0<br> 9 RxHeader c Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br> 9
RxHeader c Accept-Language: en-us,en;q=0.5<br> 9 RxHeader c Accept-Encoding: gzip, deflate<br> 9 RxHeader c Connection: keep-alive<br> 9 RxHeader c Cookie: __utma=163271977.1649200775.1339623409.1339678556.1339688677.4; AutoLogin=aa0cb1ba10b4f859d5ab6eab2fe8cb6f4be48867%7E7b40ad672393bf7738c6d065101f44283396ef11; __utmz=163271977.1339661812.2.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __un<br> 9 VCL_call c recv lookup<br> 9 VCL_call c hash<br> 9 Hash c /auth/login<br> 9 Hash c website.com<br> 9 VCL_return c hash<br> 9
VCL_call c miss fetch<br> 9 FetchError c no backend connection<br> 9 VCL_call c error deliver<br> 9 VCL_call c deliver deliver<br> 9 TxProtocol c HTTP/1.1<br> 9 TxStatus c 503<br> 9 TxResponse c Service Unavailable<br> 9 TxHeader c Server: Varnish<br> 9 TxHeader c Content-Type: text/html; charset=utf-8<br> 9 TxHeader c Retry-After: 5<br> 9 TxHeader c Content-Length: 418<br> 9 TxHeader c Accept-Ranges: bytes<br> 9 TxHeader c Date: Fri, 15 Jun 2012 09:20:01
GMT<br> 9 TxHeader c X-Varnish: 905690731<br> 9 TxHeader c Age: 0<br> 9 TxHeader c Via: 1.1 varnish<br> 9 TxHeader c Connection: close<br> 9 Length c 418<br> 9 ReqEnd c 905690731 1339752001.003274202 1339752001.003641129 0.000065327 0.000314951 0.000051975<br> 9 SessionClose c error<br> 9 StatSess c xxx.xxx.xxx.xxx 49940 0 1 1 0 0 0 256 418<br> 0 CLI - Rd ping<br> 0 CLI - Wr 200 19 PONG 1339752003 1.0<br> 0 CLI
- Rd ping<br> 0 CLI - Wr 200 19 PONG 1339752006 1.0<br> 0 CLI - Rd ping<br> 0 CLI - Wr 200 19 PONG 1339752009 1.0<br> 0 CLI - Rd ping<br># ---- end varnish log<br><br># ---- start /etc/defaults/varnish<br>START=yes<br>NFILES=131072<br>MEMLOCK=82000<br>DAEMON_OPTS="-a website.com:80 \<br> -T drr0003:6082 \<br> -f /etc/varnish/website.vcl \<br> -S /etc/varnish/secret \<br> -s
malloc,2G"<br># ---- end /etc/defaults/varnish<br><br># ---- start /etc/varnish/website.vcl<br># server 1<br>backend drr0001 {<br> .host = "drr0001";<br> .port = "80";<br> .probe = {<br> .url = "/";<br> .interval = 10m;<br> .timeout = 500s;<br> .window = 5;<br> .threshold = 3;<br> }<br>}<br><br># server 2<br>backend drr0002 {<br> .host = "drr0002";<br> .port = "80";<br> .probe =
{<br> .url = "/";<br> .interval = 10m;<br> .timeout = 500s;<br> .window = 5;<br> .threshold = 3;<br> }<br><br>}<br><br># server 3<br>backend drr0003 {<br> .host = "drr0003";<br> .port = "80";<br> .probe = {<br> .url = "/";<br> .interval =
10m;<br> .timeout = 500s;<br> .window = 5;<br> .threshold = 3;<br> }<br><br>}<br><br># Round-Robin load balance<br>director website round-robin {<br> {<br> .backend = drr0001;<br> }<br> {<br> .backend = drr0002;<br> }<br>
{<br> .backend = drr0003;<br> }<br>}<br><br># ACL to allow cache Purge<br>acl purge {<br> "drr0001";<br> "drr0002";<br> "drr0003";<br>}<br><br># Receive<br>sub vcl_recv {<br> # check acl purge at the top and purges<br> if (req.request == "PURGE") <br> {<br> if (!client.ip ~ purge) {<br> error 404 "Not Found";<br> }<br> return (lookup);<br> }<br> <br> if (!
req.http.Host)<br> {<br> error 404 "Your query need a host header !";<br> }<br> if (req.http.Host ~ "website.com")<br> {<br> set req.backend = website;<br> include "/etc/varnish/website-esi-recv.vcl";<br> }<br> else<br> {<br> error 404 "No Varnish configuration for your host header.";<br> }<br>}<br><br>## FETCH<br>sub vcl_fetch {<br> if (req.http.Host ~ "test.website.com")<br> {<br> include "/etc/varnish/website-esi-fetch.vcl";<br> }<br> else<br> {<br> return (deliver);<br>
}<br>}<br><br># HIT<br>sub vcl_hit {<br> if (req.request == "PURGE") {<br> purge;<br> error 200 "Purged.";<br> }<br>}<br><br># MISS<br>sub vcl_miss {<br> if (req.request == "PURGE") {<br> purge;<br> error 200 "Purged.";<br> }<br>}<br><br><br>## DELIVER<br>sub vcl_deliver {<br> # Secure the header<br> # remove resp.http.Via;<br> # remove resp.http.X-Varnish;<br> # remove resp.http.Server;<br> # remove resp.http.X-Powered-By;<br>}<br># ---- end /etc/varnish/website.vcl<br><br># ---- start /etc/varnish/website-esi-recv.vcl<br># Compatiblity with Apache log<br>remove req.http.X-Forwarded-For;<br>set req.http.X-Forwarded-For =
client.ip;<br><br># Post requests will not be cached<br>if (req.request == "POST") <br>{<br> return (pass);<br>}<br><br># Normalize encoding/compression<br>if (req.http.Accept-Encoding) <br>{<br> if (req.http.Accept-Encoding ~ "gzip") <br> { <br> set req.http.Accept-Encoding = "gzip"; <br> }<br> elsif (req.http.Accept-Encoding ~ "deflate") <br> { <br> set req.http.Accept-Encoding = "deflate"; <br> }<br> else <br> { <br> remove req.http.Accept-Encoding; <br> }<br>}<br><br># Serve the page<br>unset req.http.vary;<br><br>if (req.url ~ "\.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)$") {<br> # Remove the
cookie and make the request static<br> unset req.http.cookie;<br> return (lookup);<br>}<br># Try to lookup in the cache<br>return (lookup);<br><br># Cookie ? Not cacheable by default<br>if (req.http.Authorization || req.http.Cookie) {<br> return (pass);<br>}<br># ---- end /etc/varnish/website-esi-recv.vcl<br><br># ---- start /etc/varnish/website-esi-fetch.vcl<br># Enable ESI<br>set beresp.do_esi = true;<br>set beresp.ttl = 0s;<br><br># Defining TTL for specific URLs<br>if (req.url ~ "\.(ico|js|css)$") {<br> set beresp.ttl = 24h;<br>}<br><br>if (req.url ~ "\/other1\/([0-9]+$)\/") {<br> set beresp.ttl = 10s;<br>}<br>if (req.url ~ "\/other2\/([0-9]+$)\/") {<br> set beresp.ttl = 24h;<br>}<br><br>return (deliver);<br># ---- end /etc/varnish/website-esi-fetch.vcl<br></font></div></div></body></html>