Varnish 4.0 Error: VCL sub's named 'vcl*' are reserved names.

April 29, 2014 4.8k views
Today i installed varnish 4.0 on my ubuntu 14.04 (LEMP) droplet for Wordpress hosting. I try to config Vartish 4.0 with this tutorial: https://www.digitalocean.com/community/articles/how-to-install-wordpress-nginx-php-and-varnish-on-ubuntu-12-04 but, when i try to restart varnish, i see this error: * Starting HTTP accelerator varnishd [fail] Message from VCC-compiler: VCL sub's named 'vcl*' are reserved names. ('input' Line 29 Pos 5) sub vcl_fetch { ----#########-- Valid vcl_* methods are: vcl_recv vcl_pipe vcl_pass vcl_hash vcl_purge vcl_miss vcl_hit vcl_deliver vcl_synth vcl_backend_fetch vcl_backend_response vcl_backend_error vcl_init vcl_fini Running VCC-compiler failed, exit 1 VCL compilation failed In varnish 4.0 is vcl_* reserved "Any custom-made subs cannot be named 'vcl_*' anymore. This namespace is reserved for builtin subs." https://www.varnish-cache.org/docs/trunk/whats-new/upgrading.html How i need to change this code: # Drop any cookies Wordpress tries to send back to the client. sub vcl_fetch { if (!(req.url ~ "wp-(login|admin)")) { unset beresp.http.set-cookie; } } , for solve this error?
2 Answers
vcl_fetch is now vcl_backend_response https://www.varnish-cache.org/docs/trunk/whats-new/upgrading.html

Try replacing vcl_fetch with vcl_backend_response.
  • Doesn't seem to help

    • Stopping HTTP accelerator varnishd [fail]
    • Starting HTTP accelerator varnishd [fail] Message from VCC-compiler: 'req.url': Not available in method 'vclbackendresponse'. At: ('input' Line 36 Pos 15) if (!(req.url ~ "wp-(login|admin)")) { --------------#######-------------------------

    Running VCC-compiler failed, exit 1

    VCL compilation failed

  • Actually, this seems to help.. not sure if this is technically correct though:

    sub vclbackendresponse {

        if (!(bereq.url ~ "wp-(login|admin)")) {
                unset beresp.http.set-cookie;
        }
    

    }

Have another answer? Share your knowledge.