Example config for CMS Made Simple
An example
varnish config for
cmsms (CMS Made Simple)
backend reflex {
.host = "85.214.82.33";
.port = "180";
}
backend guanin {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_recv {
if (req.http.host ~ "^(www.)?s2p.de$") {
# normalise the host for cache efficience
set req.http.host = "s2p.de";
set req.backend = guanin;
} elseif (req.http.host ~ "^(www.)?reflex.de$") {
set req.http.host = "reflex.de";
set req.backend = reflex;
} elseif (req.http.host ~ "^wiki.s2p.de$") {
set req.http.host = "s2p.de";
set req.backend = guanin;
} else {
error 404 "Unknown virtual host";
}
if ( req.request == "GET" && req.http.cookie && !( req.url ~ "^/admin/") ) {
return(lookup);
}
if ( req.backend.healthy) {
set req.grace = 30s;
} else {
set req.grace = 1h;
}
}
sub vcl_fetch {
set beresp.grace = 1h;
if ( beresp.ttl < 300s ) {
#log " ### Adjusting TTL to 300s";
set beresp.ttl = 300s;
}
if ( beresp.http.set-cookie ) {
return(deliver);
}
}
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
}