banning in one line command
miguel_3_gonzalez at yahoo.es
Thu Feb 2 13:44:18 CET 2017
On 02/02/17 1:05 PM, Dridi Boukelmoune wrote:
>>> you mean varnishadm manual, this one:
> Yes, I was looking at something else related to varnishstat and endup
> mixing things up. That's the manual I'm referring to.
>>> My experience is that using a singleliner doesn´t work, cache is not
>>> banned. I thought It was the empty string output but considering your
>>> answer and the manual it supposedly works but it´s not actually banning
>>> the cache.
> It works for me:
> $ cat ban_test.sh
> set -e
> if varnishadm ban "$1"
> echo "Ban added."
> varnishadm ban.list
> echo "Failed to add ban." >&2
> exit 1
> $ ./ban_test.sh "req.url ~ /foo"
> Ban added.
> Present bans:
> 1486036564.163640 0 - req.url ~ /foo
> 1486036505.008676 0 C
> $ ./ban_test.sh "req.url =="
> Unknown request.
> Type 'help' for more info.
> Too few parameters
> Command failed with error code 104
> Failed to add ban.
>> using quotes an after the example in the manual:
>> echo "ban req.http.host ~ myserver.com" | varnishadm -S /etc/varnish/secret
> You shouldn't need to specify -S for a local access with varnishadm.
>> Before I was getting this error when not using commands for the echo
>> command (as showed in the example in the manual):
>> expected conditional (~, !~, == or !=) got "/root"
>> apparently this error is dued to the echo command and the use of
>> conditionals as ~
> I suspect you were getting a shell expansion of ~ to the home
> directory of the root user, hence the /root.
Yes, i did :)
Many thanks for your throughly answer!
More information about the varnish-misc