Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Varnish 3: "Expected return action name" when using "synth"

Using Varnish 3.0.7. In order to forward any non-SSL connections I've added the following subroutine to my VCL:

sub vcl_synth {
    if (resp.status == 750) {
         set resp.status = 301;
         set resp.http.Location = req.http.x-redir;
         return(deliver);
    }
}

And then in vcl_recv I've added:

if ((req.http.host ~ "^(?i)mydomain(?i)") && req.http.X-Forwarded-Proto !~ "(?i)https") {
    set req.http.x-redir = "https://" + req.http.host + req.url;
    return(synth(750, ""));
}

But I'm getting the following error:

Message from VCC-compiler:
Expected return action name.
('input' Line 225 Pos 16)
        return(synth(750, "")); 
---------------#####------------

Does anyone know why this is happening? I'm clueless after several hours of debugging...

Many thanks!

like image 367
Fredrik Avatar asked Dec 30 '15 12:12

Fredrik


1 Answers

vcl_synth and return(synth(750, "")) do not exists in Varnish Cache 3.x. That's valid syntax only in 4.x. In 3.x vcl_synth should be replaced by vcl_error and return(synth(750, "")) by error 750.

like image 193
Carlos Abalde Avatar answered Oct 23 '22 11:10

Carlos Abalde