Virtualhost issue
Vladimir Dyachenko
vlad.dyachenko at gmail.com
Tue Nov 3 12:56:18 CET 2009
Folks,
I have changed the configuration to the following (mostly based on
mediawiki). Any idea why it does not restart? Sill empty logs.
[root at net2 ~]# varnishd -V
varnishd (varnish-2.0.4)
Copyright (c) 2006-2009 Linpro AS / Verdens Gang AS
[root at net2 ~]# cat /etc/varnish/default.vcl
# set default backend if no server cluster specified
backend default {
.host = "www.google.ru";
.port = "80";
}
backend google-bg {
.host = "www.google.bg";
.port = "80";
}
backend google-pl {
.host = "www.google.pl";
.port = "80";
}
# access control list for "purge": open to only localhost and other local
nodes
acl purge {
"localhost";
}
# vcl_recv is called whenever a request is received
sub vcl_recv {
# Serve objects up to 2 minutes past their expiry if the backend
# is slow to respond.
set req.grace = 120s;
# Use our round-robin "apaches" cluster for the backend.
if (req.http.host ~ "^(www.)?google.bg$ <http://www.)/?google.bg$>")
{
set req.http.host = "www.google.bg";
set req.backend = google-bg;
}
elsif (req.http.host ~ "^(www.)?google.pl$<http://www.)/?google.pl$>")
{
set req.http.host = "www.google.pl";
set req.backend = google-pl;
}
else {
set req.backend = default;
}
# This uses the ACL action called "purge". Basically if a request to
# PURGE the cache comes from anywhere other than localhost, ignore
it.
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
lookup;
}
# Pass any requests that Varnish does not understand straight to the
backend.
if (req.request != "GET" && req.request != "HEAD" &&
req.request != "PUT" && req.request != "POST" &&
req.request != "TRACE" && req.request != "OPTIONS" &&
req.request != "DELETE")
{pipe;} /* Non-RFC2616 or CONNECT which is weird. */
# Pass anything other than GET and HEAD directly.
if (req.request != "GET" && req.request != "HEAD")
{pass;} /* We only deal with GET and HEAD by default */
# Pass requests from logged-in users directly.
if (req.http.Authorization || req.http.Cookie)
{pass;} /* Not cacheable by default */
# Pass any requests with the "If-None-Match" header directly.
if (req.http.If-None-Match)
{pass;}
# Force lookup if the request is a no-cache request from the client.
if (req.http.Cache-Control ~ "no-cache")
{purge_url(req.url);}
# normalize Accept-Encoding to reduce vary
if (req.http.Accept-Encoding) {
if (req.http.User-Agent ~ "MSIE 6") {
unset req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
unset req.http.Accept-Encoding;
}
}
lookup;
}
sub vcl_pipe {
# Note that only the first request to the backend will have
# X-Forwarded-For set. If you use X-Forwarded-For and want to
# have it set for all requests, make sure to have:
# set req.http.connection = "close";
# This is otherwise not necessary if you do not do any request
rewriting.
set req.http.connection = "close";
}
# Called if the cache has a copy of the page.
sub vcl_hit {
if (req.request == "PURGE")
{purge_url(req.url);
error 200 "Purged";}
if (!obj.cacheable)
{pass;}
}
# Called if the cache does not have a copy of the page.
sub vcl_miss {
if (req.request == "PURGE")
{error 200 "Not in cache";}
}
# Called after a document has been successfully retrieved from the backend.
sub vcl_fetch {
# set minimum timeouts to auto-discard stored objects
# set obj.prefetch = -30s;
set obj.grace = 120s;
if (obj.ttl < 48h) {
set obj.ttl = 48h;}
if (!obj.cacheable)
{pass;}
if (obj.http.Set-Cookie)
{pass;}
# if (obj.http.Cache-Control ~ "(private|no-cache|no-store)")
# {pass;}
if (req.http.Authorization && !obj.http.Cache-Control ~ "public")
{pass;}
}
Any hint most welcome.
Regards.
Vladimir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20091103/1f83d348/attachment-0001.html>
More information about the varnish-misc
mailing list