Edit sub vcl_recv and add the following
sub vcl_recv {Create...
# Ban outside access to #/user, /admin etc
# works if you : if (req.url ~ "^/user" || req.url ~ "^/admin") {
if ( (req.url ~ "^/user" || req.url ~ "^/admin" ) && !client.ip ~ yourallowedip) {
# Have Varnish throw the error directly.
error 405 "Sorry";
}
#Other code
#....
}
acl yourallowedip {Restart varnish and you will be good to go.
"1.1.1.1";
}
service restart varnish
It is always good to test your configuration before restarting Varnish. The command to do is below. It there is an error it will let you know otherwise you will get a long display.
varnishd -C -f
/etc/varnish/default
.vcl
References