Unset in Varnish - syntax error
I'm trying to hide the "Server" header returned by Apache on every request from Varnish.
Usage in sub vcl_fetch:
unset obj.http.Server;
At the beginning of the varnish I get:
Expected action, 'if' or '}'
(/etc/varnish/default.vcl Line 43 Pos 9)
unset obj.http.Server;
--------#####-----------------
Any ideas?
a source to share
In recent versions (series 2.1) the response object is called beresp and something like this in vcl_fetch works (I just tested it on Varnish 2.1.0):
unset beresp.http.Server;
I installed the version you are using (1.1.2) and got the same behavior you mentioned; it looks like the unset keyword doesn't work, at least not in the vcl_fetch function. This is odd since at least one example I have found mentions the use of unset for this exact purpose .
If possible, I suggest upgrading to the latest polish, as I think it is unlikely that if the unspecified behavior you are seeing is a bug, the team will be ready to fix it.
Preventing you from trying to install the server on something else:
set obj.http.Server = "";
set obj.http.Server = "BogoServer Whatever";
Assuming your goal is to hide the server signature. If you want to exclude the title entirely, I would venture to say that this cannot be done with your varnish version.
a source to share
I went around to install Varnish 2.1.2 which is the latest version to date. I don't get any syntax errors anymore, but the desired effect is not being applied. This enduring headline still exists.
sub vcl_fetch {
unset beresp.http.Server;
set beresp.http.Server = "Apache";
}
I am using Firebug to peek into headers, this is what I see:
Server Apache/2.2.9 (Debian)
I've tried some options like just unsetting and not setting, nothing works.
Could this be a logic problem? Perhaps the unset needs to be placed in a different south . I tried to place it in both vcl_miss and vcl_deliver. Got "Variable" beresp.http.Server "not available in method". Both times.
I have also tried setting up a custom header and removing it. It didn't work either.
a source to share