I ran in to an issue using Varnish 3 with the varnish module (7.x-1.0-beta3). From what I can tell the issue appears to be that I am viewing pages through varnish on a different server then the domain where drupal is. When the drupal server sends the ban it has the drupal host and not the varnish host which is being used to view pages. Therefore the varnish cache doesn't get cleared. I am using the expire module and have the setting to "Include base URL in expires" unchecked.
I am not sure if this is the correct approach or I am missing something. I am attaching a patch that will check if the expire module and the base url setting are set and if so exclude the req.http.host which seems to have solved the issue of bans not clearing varnish.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | varnish-remove-host-with-base-path-2558729-3.patch | 854 bytes | natew |
| #2 | varnish-remove-host-with-base-path-2558729-1.patch | 861 bytes | natew |
Comments
Comment #2
natew commentedpatch attached
Comment #3
natew commentedRe-rolled patch with different line number (I had other patches applied).
Comment #4
mgiffordComment #5
bibo commentedWorks perfectly for me. The patch is very small with a clear purpose.
This may solve some issues with Varnish on a different host, but afaik the base issue is also about the $base_url which Drupal has on each bootstrap.
For example if no $base_url is defined in settings.php, any purging actions initiated via drush (cron etc) result in a broken hostname "default"). This which can be verified by looking at varnishlog. This command:
drush vp "some/path"Will look like this in varnishlog (Varnish 3.x)
0 CLI - Rd ban req.http.host ~ default && req.url ~ ^test$The full part "req.http.host ~ default" should either be removed or include the correct base url(s) (hostname only). In case domain_access is used, there may be many base url, each node may be avaiable via 20 domains etc. In that case it makes no sense at all either purge one with path "^test$", its best the leave the host-restriction totally out of the picture. Which is exactly what this patch does.
I have to say this solves basically all problems I have with the combination of expire + varnish + domain_access.
PS: I contributed to a related expire issue 2 years ago, which affects how to base_url is handled. I should have created a patch like this back then for Varnish. Instead I created some other solutions for multidomain-cache flushes, for example a custom rules action, which allowed ".*" to be put in the place of the hostname. But this simple patch is a better solution.
Comment #6
miroslavbanov commentedI have a few objections here: