Virtualhost issue
Vladimir Dyachenko
vlad.dyachenko at gmail.com
Mon Nov 2 14:59:17 CET 2009
Folks,
I am discovering Varnish which looks like a gift from Gods, or from
Poul-Henning.
We have one case where clients gets big DDoS and we distibute HTTP servers
between various ISP. I have set it up alright for one host, but now I need
to do virtualhost as we have various sites.
Upon restart varnish does not start (no error and nothing in logs).
Wondering what obvious I did wrong.
Here is my configuration:
/// start
# This is a basic vcl.conf file for varnish.
backend default {
set backend.host = "localhost";
set backend.port = "80";
}
backend mysite1-com {
set backend.host = "www.mysite1.com";
set backend.port = "80";
}
backend mysite2-com {
set backend.host = "www.mysite2.com";
set backend.port = "80";
}
acl purge {
"localhost";
}
sub vcl_recv {
# Knock knock, who's there ?
if (req.http.host ~ "^(www|www2|www3\.)?mysite1\.com$") {
set req.backend = mysite1-com;
}
elseif (req.http.host ~ "^(www|www2|www3\.)?mysite2\.com$") {
set req.backend = mysite2-com;
}
else {
error 404 "Unknown virtual host";
}
if (req.request != "GET" && req.request != "HEAD") {
# PURGE request if zope asks nicely
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
lookup;
}
pipe;
}
if (req.http.Expect) {
pipe;
}
if (req.http.Authenticate || req.http.Authorization) {
pass;
}
# We only care about the "__ac.*" cookies, used for authentication
if (req.http.Cookie && req.http.Cookie ~
"__ac(|_(name|password|persistent))=") {
pass;
}
# File type that we will always cache
if (req.request == "GET" && req.url ~
"\.(gif|jpg|swf|css|js|png|jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|css|js|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|sxw|zip|gz|bz2|tgz|tar|rar)$")
{
lookup;
lookup;
}
if (req.request == "POST") {
pipe;
}
# force lookup even when cookies are present
if (req.request == "GET" && req.http.cookie) {
lookup;
}
if (req.http.Cache-Control ~ "no-cache") {
pass;
}
lookup;
}
sub vcl_fetch {
# force minimum ttl of 300 seconds
if (obj.ttl < 3000s) {
set obj.ttl = 3000s;
}
}
# Do the PURGE thing
sub vcl_hit {
if (req.request == "PURGE") {
set obj.ttl = 0s;
error 200 "Purged";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
error 404 "Not in cache";
}
}
/// end
Any help is most welcome.
Regards.
- Vladimir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20091102/380241be/attachment-0001.html>
More information about the varnish-misc
mailing list