[Varnish] #536: Suggested regsub example for Plone VirtualHostBase replacement

Varnish varnish-bugs at projects.linpro.no
Fri Aug 14 23:59:08 CEST 2009


#536: Suggested regsub example for Plone VirtualHostBase replacement
---------------------------+------------------------------------------------
 Reporter:  ned14          |        Owner:                     
     Type:  documentation  |       Status:  new                
 Priority:  lowest         |    Milestone:  Varnish 2.1 release
Component:  documentation  |      Version:  trunk              
 Severity:  trivial        |   Resolution:                     
 Keywords:                 |  
---------------------------+------------------------------------------------
Comment (by ned14):

 My most deepest apologies - the clipping was definitely my fault when
 copying and pasting. Here it is in all its glory:

 {{{
         if (req.http.host ~ "^(www\.|ipv6\.)?([-0-9a-
 zA-Z]+)\.([a-zA-Z]+)$") {
                 set req.http.host = regsub(req.http.host,
 "^(www\.|ipv6\.)?([-0-9a-zA-Z]+)\.([a-zA-Z]+)$", "\1\2.\3");
                 set req.url = "/VirtualHostBase/" req.http.X-Forwarded-
 Proto
                         regsub(req.http.host, "^(www\.|ipv6\.)?([-0-9a-
 zA-Z]+)\.([a-zA-Z]+)$", "/\1\2.\3:")
                         req.http.X-Forwarded-Port
                         regsub(req.http.host, "^(www\.|ipv6\.)?([-0-9a-
 zA-Z]+)\.([a-zA-Z]+)$", "/\2.\3/\2.\3/VirtualHostRoot")
                         req.url;
         }
 }}}

 I haven't tested this for speed impact, but seeing as I have eight servers
 on the same host any penalty is worth it for me.

 Cheers,
 Niall

-- 
Ticket URL: <http://varnish.projects.linpro.no/ticket/536#comment:3>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator


More information about the varnish-bugs mailing list