0

I have a few question about Varnish configuration. I've got this simple config file:

backend default {
  .host = "127.0.0.1";
  .port = "80";
}

sub vcl_recv {

if (req.http.Host == "192.168.1.100")
  {
    set req.http.Location = "http://example.com" req.url;
    error 750 "Permanently moved - TEST";
  }
}

sub vcl_error {

if (obj.status == 750) {
  set obj.http.Location = req.http.Location;
  set obj.status = 301;
  return(deliver);
 }
}

Question:

(1) I've followed this example: set req.http.Location = "http://example.com" + req.url; - however I'm not able to reload Varnish unless I remove this + symbol - is it required and what's the purpose of it?

# /etc/init.d/varnish reload
Loading vcl from /etc/varnish/default.vcl
Current running config name is reload_2013-12-17T15:01:43
Using new config name reload_2013-12-17T15:18:31
Message from VCC-compiler:
Expected variable, string or semicolon
(input Line 124 Pos 58)
    set req.http.Location = "http://example.com" + req.url;
---------------------------------------------------------#---------
Running VCC-compiler failed, exit 1VCL compilation failed
Command failed with error code 106
varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 vcl.load failed
3

In 2.1 string concatenation looks like this:

set req.http.Location = "http://example.com" req.url;

In 3.0 this was done explicitly using "+".

https://www.varnish-cache.org/docs/3.0/installation/upgrade.html#string-concatenation-operator

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.