Reputation: 9965
My Varnish VCL code needs to make a simple GET request into a backend system and decide if the requested resource is accessible or not. Unfortunately, the backend system always returns 200, and I must examine the actual body of the response to decide.
Is there a way to access the response body (which is under 1KB) in VCL and do a substring search on it?
I am trying to avoid implementing a proxy service just for this feature.
P.S. For now I have to stick with Varnish 2.1 (Fastly)
Upvotes: 2
Views: 1112
Reputation: 759
With varnish You probably should use external vmods for that
Opensource version: body-access in https://github.com/varnish/varnish-modules
Varnish Software/Entrprise : https://docs.varnish-software.com/varnish-enterprise/vmods/xbody/
Upvotes: 0
Reputation: 168
There is a way for some time now: You can use the .match_body()
method of regex objects provided by vmod_re.
Upvotes: 0
Reputation: 619
Quick answer: no. Fastly's Varnish has diverged a lot from mainline, so you are basically stuck with what they provide and response body analysis isn't part of it.
Varnish 6.0 and 6.1 internals make that easier to build, but at the moment the vmod (xbody) you need is only available as a commercial product.
Upvotes: 4