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?

+2


a source to share


4 answers


Fixed.



I had a return (pipe) in vcl_recv which made varnish never go into vcl_fetch where I disabled the header.

+1


a source


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.

+2


a source


I am using Varnish 1.1.2 Also checked with beresp and same error occurs.

He likes something wrong with unidentified. Here's a full sample:

sub vcl_fetch {
    unset obj.http.Server;
    # force minimum ttl of 6 hours
    if (obj.ttl < 6h) {
            set obj.ttl = 6h;
    }
}

      

+1


a source


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.

+1


a source







All Articles