Rewriting URL's or Content inside a req object using regsub or regsuball

Harry Yeh hyeh at rupaz.com
Fri Jan 7 06:28:24 CET 2011


I am currently having some success with the Reverse Proxying features of
Varnish, and the only thing left that I need to be able to do is essentially
rewrite some of the URL's in the body.

For example, we have a url internally that might be wp1.rupaz.com and we
need the url's in the HTML page to be rewritten to
http://www.rupaz.com/blogs

Right now I am kind of stuck but I am assuming I should be doing something
similar to following? I have not idea which beresp object I should use for
the body of the content since there is no documentation.


 sub vcl_fetch {

if (req.http.host == "www.rupaz.com" && req.url ~ "^/blogs"){
 set beresp = regsuball(beresp, "^wp1.rupaz.com", "www.rupaz.com/forums");
 return(deliver);
}
      if (!beresp.cacheable) {
         return (pass);
     }
     if (beresp.http.Set-Cookie) {
         return (pass);
     }
     return (deliver);
 }


______________________________

Harry Yeh
CEO / CTO
Rupaz
Twitter <http://twitter.com/rupaztweet>
Facebook <http://www.facebook.com/pages/Rupaz/175747085776028>
When you think thong <http://www.rupaz.com/>, think Rupaz<http://www.rupaz.com/>
!

Web: http://www.rupaz.com <http://www.ooolalashop.com/>
Me: http://www.linkedin.com/in/harryyeh
Twitter: http://twitter.com/harryyeh
Confidentiality Notice:

This electronic mail transmission and any accompanying attachments contain
confidential information intended only for the use of the individual or
entity named above. Any dissemination, distribution, copying or action taken
in reliance on the contents of this communication by anyone other than the
intended recipient is strictly prohibited. If you have received this
communication in error please immediately delete the E-mail and notify the
sender at the above E-mail address.




-- 
Regards,

______________________________

Harry Yeh
CEO / CTO
Rupaz
Direct: (310)974-8938
Direct: (604)304-1603
Fax:    (310)494-9363
Twitter <http://twitter.com/rupaztweet>
Facebook <http://www.facebook.com/pages/Rupaz/175747085776028>
When you think thong <http://www.rupaz.com/>, think Rupaz<http://www.rupaz.com/>
!

Web: http://www.rupaz.com <http://www.ooolalashop.com/>
Me: http://www.linkedin.com/in/harryyeh
Twitter: http://twitter.com/harryyeh
Confidentiality Notice:

This electronic mail transmission and any accompanying attachments contain
confidential information intended only for the use of the individual or
entity named above. Any dissemination, distribution, copying or action taken
in reliance on the contents of this communication by anyone other than the
intended recipient is strictly prohibited. If you have received this
communication in error please immediately delete the E-mail and notify the
sender at the above E-mail address.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110106/433ae728/attachment-0003.html>


More information about the varnish-misc mailing list