Sunday, January 25, 2015

Using Varnish to block access to specific folders

If you ever need to block folder or folders using Varnish Cache, here are the simple steps.

Edit  sub vcl_recv and add the following
sub vcl_recv {
  # 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
#....
}
Create...
acl yourallowedip {
    "1.1.1.1";
}
Restart varnish and you will be good to go.

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

Audio Noise Removal

Many times in record clips we end up with unwanted background noise. Recently faced with the situation, I  needed to clean up some audio and...