backend node1 { .host = "XXX.XXX.XXX.XXX"; .port = "80"; .connect_timeout = 600s; } director default_director round-robin { { .backend = node1; } } sub vcl_recv { set req.backend = default_director; set req.grace = 5m; if (req.http.x-forwarded-for) { set req.http.X-Forwarded-For = req.http.X-Forwarded-For ", " client.ip; } else { set req.http.X-Forwarded-For = client.ip; } if (req.http.Accept-Encoding) { if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|mp4|swf)$") { # No point in compressing these remove req.http.Accept-Encoding; } else if (req.http.Accept-Encoding ~ "gzip") { set req.http.Accept-Encoding = "gzip"; } else if (req.http.Accept-Encoding ~ "deflate") { set req.http.Accept-Encoding = "deflate"; } else { # unknown algorithm remove req.http.Accept-Encoding; } } if (req.request != "GET" && req.request != "HEAD" && req.request != "PUT" && req.request != "POST" && req.request != "TRACE" && req.request != "OPTIONS" && req.request != "DELETE") { /* Non-RFC2616 or CONNECT which is weird. */ return (pipe); } if (req.request != "GET" && req.request != "HEAD") { /* We only deal with GET and HEAD by default */ return (pass); } return (lookup); } sub vcl_pipe { set req.http.connection = "close"; return (pipe); } sub vcl_pass { return (pass); } sub vcl_hash { } sub vcl_hit { if (!obj.cacheable) { return (pass); } return (deliver); } sub vcl_miss { return (fetch); } sub vcl_fetch { # Grace to allow varnish to serve content if backend is lagged set beresp.grace = 5m; # These status codes should always pass through and never cache. if (beresp.status == 404 || beresp.status == 503 || beresp.status == 500 || !beresp.cacheable) { return (pass); } if (req.url ~ "\.(png|gif|jpg|swf|css|js|mp3|mp4)$") { unset beresp.http.set-cookie; } return (deliver); } sub vcl_deliver { return (deliver); } sub vcl_error { set obj.http.Content-Type = "text/html; charset=utf-8"; synthetic {" "} obj.status " " obj.response {"

Error "} obj.status " " obj.response {"

"} obj.response {"

Guru Meditation:

XID: "} req.xid {"


Varnish cache server

"}; return (deliver); }