Expected ';' got 'req.url'

Nguyen Long longvnit at gmail.com
Wed Mar 28 18:15:58 CEST 2012


I used the vcl code to redirect website to mobile version as follow

sub vcl_recv {
        if ((req.http.User-Agent ~ "iP(hone|od)" || req.http.User-Agent ~
"Android" || req.http.User-Agent ~ "Symbian" || req.http.User-Agent ~
"^BlackBerry" || req.http.User-Agent ~ "^SonyEricsson" ||
req.http.User-Agent ~ "^Nokia" || req.http.User-Agent ~ "^SAMSUNG" ||
req.http.User-Agent ~ "^LG" || req.http.User-Agent ~ "webOS" ||
req.http.User-Agent ~ "^PalmSource") && req.http.host ~ "^(www.vechai.info|
vechai.info)") {
               error 750 "Moved Temporarily";
        }
}

sub vcl_error {
  if (obj.status == 750) {
      set obj.http.Location = "http://domain.com" req.url;
    set obj.status = 302;
    return(deliver);
  }
}

But when I use above code on Centos has kernel version is Linux
localhost.localdomain 2.6.32-71.el6.x86_64 #1 SMP Fri May 20 03:51:51 BST
2011 x86_64 x86_64 x86_64 GNU/Linux then every things is ok.
But when I use bove code on Centos has kernel version is Linux
server6.vina84.com 2.6.18-308.1.1.el5 #1 SMP Wed Mar 7 04:16:51 EST 2012
x86_64 x86_64 x86_64 GNU/Linux then fail :(
Both OS updated latest version.

Error as follow:
Message from VCC-compiler:
Expected ';' got 'req.url'
(program line 174), at
('input' Line 121 Pos 64)
                set obj.http.Location = "http://domain.com" req.url;
---------------------------------------------------------------#######-

Running VCC-compiler failed, exit 1
VCL compilation failed
Command failed with error code 106

And when I change  "set obj.http.Location = "http://domain.com" req.url;"
to " set obj.http.Location = "http://domain.com";" then varnish is aleady
running.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120328/88c1431b/attachment.html>


More information about the varnish-misc mailing list