varnish config 4

by trisna dev

JavaScript

sub vcl_recv {
    # Allow purge requests from specific IPs
    if (req.method == "PURGE") {
        if (!client.ip ~ purge_acl) {
            return (synth(405, "Method Not Allowed"));
        }
        return (purge);
    }

    # Allow ban requests from specific IPs
    if (req.method == "BAN") {
        if (!client.ip ~ purge_acl) {
            return (synth(405, "Method Not Allowed"));
        }
        ban("req.http.host == " + req.http.host + " && req.url == " + req.url);
        return (synth(200, "Ban added"));
    }
}

acl purge_acl {
    "127.0.0.1";
    "192.168.1.0"/24;  # Contoh IP yang diizinkan
}