Correct way to raise immediate error in VCL

George george at zygmund.net
Wed Mar 7 15:48:23 CET 2012


3.0 Docs state that from vcl_recv "The vcl_recv subroutine may terminate 
with calling return() on one of the following keywords:" ... error code 
[reason]. This implies a syntax of return( error 404 "Not Found" ); - 
which I believe is incorrect and didn't work when I tried it. There are 
a number of examples of throwing errors - usually something like   error 
404 "Not Found" that I know work .

However, I can find no definitive statement that this method causes an 
IMMEDIATE return from vcl_recv. The reason I need clarification is that 
I am tracking an issue that seems to indicate that processing continues 
after an error is called and am seeing urls appearing in the backend 
server logs that indicate subsequent pipe commands may have been honored 
despite the error call.

Could someone clarify - is calling error 404 "Not Found"; sufficient to 
cause all further processing to cease and a subroutine return to be 
implicitly carried out - or is something more specific required like..

(VCL Snippit)

         #block unauthorized access to this site
         if (!client.ip ~ authorized) {
           error 404 "Not Found.";
           return (error);
         }







More information about the varnish-misc mailing list