How to match domains starting with "admin"

Abraham Cruz Sustaita abraham.sustaita at buscacorp.com
Mon Jul 9 22:05:26 CEST 2012


I have three domains with several subdomains, so I want to have them just
in one regexp

abc.domain1.com
def.domain2.com
ghi.domain2.com
jkl.domain1.com
mno.domain3.net

Is this rule ok?

if (req.http.Host ~ "^(.*?\.(domain1|domain2|domain3)\.(com|net))$") {
  set req.backend = domain1_domain2;
}

2012/7/9 Paul A. Procacci <pprocacci at datapipe.com>

> On Mon, Jul 09, 2012 at 02:47:36PM -0500, Paul A. Procacci wrote:
> > On Mon, Jul 09, 2012 at 09:57:38AM -0700, Abraham Cruz Sustaita wrote:
> > >    I have several sites on my servers, so I need to configure one admin
> > >    subdomain for each one. However, I don't want to make:
> > >
> > >    if (req.http.Host ~
> > >    "(?i)([1]admin.domain1.com|[2]admin.domain2.com|[3]
> admin.domainN.com)?$
> > >    ") {}
> > >
> > >    Can I do this only with one regular expression of the type
> > >    (admin\.(.*)) ?
> > >
> >
> > Something like the following will match anything prefix'd with `admin`.
> > You'd have to include the suffixes manually.  Luckily, there aren't too
> many
> > tld's for this to be a major concern.
> >
> > ^admin\.[^\.]+\.(?=(com|net|org))$
> >
> > You can capture the entire hostname by including grouping operators
> > around the entire regex:
> >
> > ^(admin\.[^\.]+\.(com|net|org))$
> >
> > ~Paul
>
> Sorry for the email to self here.  The second regex was a bad copy/paste
> and
> should have been:
>
> ^(admin\.[^\.]+\.(?=(com|net|org)))$
>
> ~Paul
>
> ________________________________
>
> This message may contain confidential or privileged information. If you
> are not the intended recipient, please advise us immediately and delete
> this message. See http://www.datapipe.com/legal/email_disclaimer/ for
> further information on confidentiality and the risks of non-secure
> electronic communication. If you cannot access these links, please notify
> us by reply message and we will send the contents to you.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120709/2dd62fca/attachment.html>


More information about the varnish-misc mailing list