I would like to kindly ask someone for help. I browsed a lot of pages containing Varnish tutorials and sample VCL files, but I can't find anything related to configurating Varnish for Magento (at least they don't function right).
All manuals I've found thrown a lot of errors during Varnish starting and it seems thay are suitable for old versions. (Also none of magento modules PageCache & Varnish Extension don't work for me, because I think Varnish itself is not working right)
My problem:
1. I get Varnish to cache front-end, but it breaks almost every
functionalities of my forms, payment module, newsletter subscription, etc., etc.
2. I've found out that changing one word in "sub vcl_recv" changes everything
The word is: return(lookup). This is the code of my "sub vcl_recv":
sub vcl_recv {
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(server.ip ~ a168_144_38_181){
set req.backend = b168_144_38_181;
}
}
if (req.url ~ "^/images") {
unset req.http.cookie;
}
if (req.url ~ "^(/index.php)?/(admin|customer|checkout|add|product_compare|switch|___store|referer|contact|chat|payone|sendfriend|review|api|NOCACHE|post|robots.txt|j2tajaxcheckout|cron.php|varnish)") {
return(pass);
}
if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
set req.http.user-agent = "Mozilla";
unset req.http.Https;
unset req.http.cookie;
return (lookup);
}
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);
}
#parse accept encoding rulesets to normalize
if (req.http.Accept-Encoding) {
if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
# no need of compression
remove 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 {
# unknown algorithm
remove req.http.Accept-Encoding;
remove req.http.Cookie;
remove req.http.X-Pass;
set req.grace = 30s;
return (lookup);
}
}
Can someone kindly help me with setting this up?
Any help would be greatly appreciated!!!
Thank you. Thomas