Naive use of regsub to set req.backend

Pierre Fortin Carrier pcarrier at
Mon May 5 21:24:04 CEST 2008


I am currently using Varnish 1.1.2 in front of a load balancer with
impressive success.  Congratulation for this jewel.

I recently got charmed by the idea of using VCL to send some request
directly to a specific node (bypassing the LB) for testing purpose.

I seek to avoid the advertised method proposed in VCL man page that will
lead to too much elsif in my setup.

My current attempt seem to lead to a dead end:

  backend LB {
    set = "";
    set backend.port = "8080";

  backend node1 {
    set = "";
    set backend.port = "80";

  backend node2 {
    set = "";
    set backend.port = "80";

  sub vcl_recv {
    if ( ~ "^webapp\.example\.com$") {
      set req.backend = LB;
    } elsif ( ~ "^.+\.webapp\.example\.com$") {
      set req.backend = regsub(, "\.webapp\.example\.com", "");
      set = "";
    } else {
      error 404 "This website isn't living here";

  Varnish refuse to start and complaint about:
  varnishExpected ';' got '('
    (on the regsub line)

>From what I understand I don't understand.  Did I missed something
obvious here?

Any hint would be much appreciated.


More information about the varnish-misc mailing list