logical or statement failing

Tim Dunphy bluethundr at gmail.com
Sun Aug 16 20:00:20 CEST 2015


Hi Glenn,

 Thanks for your reply! And yes that does indeed compile.

 # Allow the beta site to login
   if ( req.http.host ~ "^beta\.jokefire\.com$" &&
"^/?\?oa_social_login_source=custom$"  ) {
      return (pass);
   }

I actually remembered that the ? is a regex character and needed to be
escaped before I read your email. That got it to compile. But one thing
that I didn't think of was including the beginning slash at the start of
the regex. So instead I had this: "^\?oa_social_login_source=custom$". That
compiles too. But actually neither solution, yours nor mine, allows you to
login to my wordpress site.

So I might have to do a little more digging there on how to do this. But of
course if anyone on the list can suggest some good resources on how to
front wordpress with varnish that you like and shows you how to solve the
login problem I'm having, that would be great!

Thanks,
Tim

On Sun, Aug 16, 2015 at 4:19 AM, Glenn Slaven <glenn at squixa.com> wrote:

> Hi Tim,
>
> The problem is you need to escape the question mark in the regex like
> this:
>
> "^\?oa_social_login_source=custom$"
>
> The question maker is a regex special character meaning "match the
> previous character one or zero times.  That doesn't really work with the
> start of line character.
>
> You can see this compiling here
>
> http://www.vclfiddle.net/150816-1e0353b/3
>
> As a side note, the req.url will include the slash at the start if people
> put in this url
>
> http://beta.jokefire.com/?oa_social_login_source=custom
>
> which would be entirely valid, could I suggest something like this:
>
> "^/?\?oa_social_login_source=custom$"
>
> Glenn
>
> On 16 August 2015 at 14:01, Tim Dunphy <bluethundr at gmail.com> wrote:
>
>>
>> Hey guys,
>>
>>  I'm trying to allow logins on my site. So I setup the following in my
>> VCL under varnish 4:
>>
>> # Allow the beta site to login
>>    if ( req.http.host ~ "^beta\.jokefire\.com$" && req.url ~
>> "^?oa_social_login_source=custom$" ) {
>>       return (pass);
>>    }
>>
>> But when I go to do a syntax check on the VCL I get the following error:
>>
>> #varnishd -C -f default.vcl
>> Message from VCC-compiler:
>> Regexp compilation error:
>>
>> nothing to repeat
>>
>> ('input' Line 111 Pos 62)
>>    if ( req.http.host ~ "^beta\.jokefire\.com$" && req.url ~
>> "^?oa_social_login_source=custom$" ) {
>>
>> -------------------------------------------------------------##################################----
>>
>> Running VCC-compiler failed, exited with 2
>>
>> VCL compilation failed
>>
>>
>> Could I get a little help with the syntax to get this working?
>>
>> Thanks,
>> Tim
>> --
>> GPG me!!
>>
>> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>>
>>
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc at varnish-cache.org
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>>
>
>
>
> --
> *Glenn Slaven*
> Principal Engineer
>
> Ph: (02) 9119 0444
> M: 0433 826 255
> www.squixa.com
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>



-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20150816/133b0548/attachment.html>


More information about the varnish-misc mailing list