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

Varnish varnish-bugs at projects.linpro.no
Wed Aug 5 00:13:14 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):

 This regsub is better (less likely to err):

 {{{
         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$
                 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/Vir$
                         req.url;
         }

 }}}

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


More information about the varnish-bugs mailing list