How to modify backend content before it reach to client's browser?

Richard Chiswell richard.chiswell at mangahigh.com
Fri Feb 5 14:04:43 CET 2010


Hello Fulan,

I'm not sure what you are asking from Varnish. You could use its ESI ( 
http://varnish-cache.org/wiki/ESIfeatures ) to include additional 
content or "synthetic" ( http://varnish-cache.org/wiki/VCLSyntaxStrings 
) to set the content. I don't think you are able to change the contents 
of URLs "on the fly" in Varnish without using inline C.

If you are actually looking at redirecting URLs, you may find code such as:

sub vcl_recv {
....
if (req.url ~ "^/rgb([A-z0-9]+)$") {
        error 750 "ukredirect";
}
...
}
sub vcl_error {
...
    if (obj.status == 750) {
    if (obj.response == "ukredirect") {
         set obj.http.Location = "http://" req.http.host 
regsub(req.url,"^/rgb([A-z0-9]+)$","/en_gb/?utm_source=ukredirect&utm_medium=web&utm_campaign=\1");
         set obj.status = 301;
         set obj.response = "Found";
         deliver;
    }
}
...
}
useful to redirect the users browser without touching the backend.

Yours,
Richard

fulan Peng wrote:
> Hi,
>
> I am looking for the functionality similar to Apache's mod_proxy_html.
> It can modify backend's content before it reach to customer. I used it
> to rewrite url in the links.
>
> Usually, when people are talking about url rewriting, they mean to
> rewrite the url before send out to backend. That is varnish's url
> rewriting. That is not I want.
>
> Thanks a lot!
>
> Fulan Peng
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>   




More information about the varnish-misc mailing list