|
When I use the code below (based on the templates at
https://github.com/mattiasgeniar/varnish-3.0-configuration-templates/tree/master/conf.d),
Drupal 7 + Varnish 3 'almost' works. Varnish is working perfectly (no backend calls, two Varnish timestamps in the header). However, I can't log in in my Drupal site. Same behaviour with directories which are protected by .htaccess. The logon screen keeps popping up when I enter the correct credentials. My default.vcl: /TEMPLATE/ backend default { .host = "127.0.0.1"; .port = "80"; .connect_timeout = 600s; .first_byte_timeout = 600s; .between_bytes_timeout = 600s; } sub vcl_recv { # A configuration file specific for Drupal 7 # Either the admin pages or the login if (req.url ~ "/admin/?") { # Don't cache, pass to backend return (pass); } # Remove the "has_js" cookie set req.http.Cookie = regsuball(req.http.Cookie, "has_js=[^;]+(; )?", ""); # Remove the "Drupal.toolbar.collapsed" cookie set req.http.Cookie = regsuball(req.http.Cookie, "Drupal.toolbar.collapsed=[^;]+(; )?", ""); # Remove any Google Analytics based cookies set req.http.Cookie = regsuball(req.http.Cookie, "__utm.=[^;]+(; )?", ""); # Remove the Quant Capital cookies (added by some plugin, all __qca) set req.http.Cookie = regsuball(req.http.Cookie, "__qc.=[^;]+(; )?", ""); # Are there cookies left with only spaces or that are empty? if (req.http.cookie ~ "^ *$") { unset req.http.cookie; } # Static content unique to the theme can be cached (so no user uploaded images) if (req.url ~ "^/themes/" && req.url ~ "\.(css|js|png|gif|jp(e)?g)") { unset req.http.cookie; } # Normalize Accept-Encoding header (straight from the manual: https://www.varnish-cache.org/docs/3.0/tutorial/vary.html) if (req.http.Accept-Encoding) { if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") { # No point in compressing these 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 { # unkown algorithm remove req.http.Accept-Encoding; } } # Don't cache the install, update or cron files in Drupal if (req.url ~ "install\.php|update\.php|cron\.php") { return (pass); } # Uncomment this to trigger the vcl_error() subroutine, which will HTML output you some variables (HTTP 700 = pretty debug) #error 700; # Anything else left? if (!req.http.cookie) { unset req.http.cookie; } # Try a cache-lookup return (lookup); } sub vcl_fetch { # For static content related to the theme, strip all backend cookies if (req.url ~ "^/themes/" && req.url ~ "\.(css|js|png|gif|jp(e?)g)") { unset beresp.http.cookie; } # A TTL of 30 minutes set beresp.ttl = 1800s; } /TEMPLATE/ Regards. Mattias Geniar wrote:
|
_______________________________________________ varnish-misc mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
