When you use a specific domain name to contribute and an other for anonymous users, the ban command is sent only for contributors

Comments

mjeannin created an issue. See original summary.

mjeannin’s picture

Status: Active » Needs review
StatusFileSize
new1.77 KB
SebCorbin’s picture

  1. Some code style issues
    +++ b/varnish.module
    @@ -159,13 +159,27 @@ function varnish_purge($host, $pattern) {
    +        }	
    +      }  ¶
    ...
    +        } ¶
    +      }  ¶
    

    Space at line ends and spaces needed between operator/parenthesis, etc. See https://www.drupal.org/coding-standards

  2. +++ b/varnish.admin.inc
    @@ -74,6 +74,13 @@ function varnish_admin_settings_form() {
    +    '#default_value' => variable_get('varnish_site_domain', 'front.com'),
    ...
    +    '#description' => t('Set the front domain names separated by spaces. By default, backoffice domain name is used '),
    

    The description states that the default will be backoffice domain, but 'front.com' is used.
    You should get it from $GLOBALS['base_url'] (with http(s) stripped from it).

  3. +++ b/varnish.module
    @@ -159,13 +159,27 @@ function varnish_purge($host, $pattern) {
    +  $fronts=variable_get('varnish_site_domain');
    

    Same thing here, so that the module could run even when not configured

  4. +++ b/varnish.module
    @@ -159,13 +159,27 @@ function varnish_purge($host, $pattern) {
    +        foreach ($frontList  as &$value) {
    +          _varnish_terminal_run(array("$command req.http.host ~ $value && req.url ~ \"$pattern\""));
    

    No need to iterate over references

  5. I would also add a validate to this form element so that domain is required, otherwise flushing caches won't work at all
SebCorbin’s picture

Title: Module doesn't work with several domains » Handle several domains
Status: Needs review » Needs work
mjeannin’s picture

StatusFileSize
new1.77 KB
mjeannin’s picture

Status: Needs work » Needs review
SebCorbin’s picture

Status: Needs review » Reviewed & tested by the community

Ok so now it's more clear: front-end domain are optional, varnish will work even if no domain is set.

+++ b/varnish.admin.inc
@@ -74,6 +74,14 @@ function varnish_admin_settings_form() {
+    '#description' => t('If you have multiple front-end doamin to flush, each domain will be called when banning. Enter front domain names separated by spaces.'),

Typo here but otherwise it works for me

Anthony Hyvert’s picture

Thanks for the reply.

Do you when this patch will be integrate to the module ?

misc’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev

The patch #5 does not apply to dev, could somebody with more time than me update it?

misc’s picture

Status: Reviewed & tested by the community » Needs work
jlatorre’s picture

Patch #5 worked for me on latest 7.x-dev version

jlatorre’s picture

Status: Needs work » Needs review
cesarmiquel’s picture

Patch #5 worked like a charm for me. It applied cleanly with the 7.x-1.1 version which was released a couple of days ago.

jyrkih’s picture

StatusFileSize
new1.77 KB

Patch #5 seems to fail if variable varnish_front_domains is empty. Adding a patch which makes an extra check for emptiness.

jlatorre’s picture

Status: Needs review » Fixed

  • MiSc committed 9f8d4cd on 7.x-1.x authored by jyrki
    Issue #2598824 by mjeannin, jyrki: Handle several domains
    
misc’s picture

No, it was not fixed, but now it is :-) Committed to latest dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

socialnicheguru’s picture

I have long domain names and it would be great to have a larger area to enter in

retorque’s picture

A note for the next person using this feature and encountering performance issues with long lists of domains (we made the field accept a longer list by altering it from hook_form_alter() in a custom module):

The list of domains is processed in a loop. The number of Varnish console requests will be at least number-of-domains * number-of-varnish-servers. The number of domains seems to have a bigger impact on performance than the number of Varnish servers, but both can be an issue. We had a site with 12 domains behind 4 Varnish servers, and node save was taking close to 30 seconds, even for very simple nodes.

However, the domains are also inserted into the Varnish ban command using a regular expression operator. I suspect that was intended to eliminate the need for a separate "www" entry, but it also conveniently means that you can put a list of domains in a parenthetical group and get them all processed with a single request to Varnish.
Example:
(exampleschooldistrict.org|exampleschool.org|exampleschooltwo.com|exampleschoolthree.net)