Masquerade backend errors on 4.0.x

Cédric Jeanneret varnish at tengu.ch
Fri Jul 24 08:33:53 CEST 2015


Hello,

Just found out: documentation is wrong, vcl_deliver DOES support "synth"
as a return function…

This showed the support:
https://gist.github.com/mjf/ddae14982720f77b665a#file-varnish_cache_subroutines-rst

and a test validated it. So now I can do a synthetic(""); in vcl_synth
if we get a 204 status.

Might be good to update/correct this page:
https://www.varnish-cache.org/docs/4.0/users-guide/vcl-built-in-subs.html#vcl-deliver

Cheers,

C.

On 07/24/2015 07:56 AM, Cédric Jeanneret wrote:
> Hello,
> 
> I'm having some troubles trying to masquerade backend error with varnish
> 4.0.x.
> 
> Lemme explain:
> queries are sent to some backend server, which might return either 403
> or 200 HTTP code, both with content (403 will explain "access denied"
> with some random string, blah).
> 
> My aim is to override the 403 error with "204" (no content) and deliver
> an empty content.
> 
> Issue so far: I can set the response status to 204, but I'm unable to
> deliver an actual empty body and varnish still sets the header
> Content-Length to the backend answer length.
> 
> My thought were to put some "return(sync(204))" in vcl_backend_response,
> but this subroutine is unable to return "synth"; I tried to mess a bit
> in vcl_deliver, but there as well, unable to return "synth".
> 
> Of course, "unset *.http.Content-Length" doesn't work.
> 
> We really need to return 204 with no content, as:
> - an application would display some bad stuff if we don't return 204
> - other applications crash weirdly if we do return 204 with a
> Content-Length above 0
> 
> I'm pretty sure the vcl_deliver should be able to return synth() in
> order to allow body/content override, but… it doesn't seem to be the
> case in varnish 4.0.x :(.
> 
> Any thought or advice?
> 
> Thanks!
> 
> Cheers,
> 
> C.
> 
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
> 



More information about the varnish-misc mailing list