All pastes #478845 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-09 12:03 UTC
rendered paste body
backend krusty {
        set backend.host = "195.159.128.22"; /* krusty.idium.no */
        set backend.port = "http";
}

backend todd {
        set backend.host = "195.159.128.6";
        set backend.port = "80";
}

backend ned {
        set backend.host = "ned.idium.no";
        set backend.port = "http";
}

backend doris {
        set backend.host = "195.159.128.11"; /* doris.idium.no */
        set backend.port = "80";
}

backend patty {
        set backend.host = "195.159.128.20";
        set backend.port = "http";
}

acl purge {
        "localhost";
        "195.159.128.0/27";
        "195.159.7.8/29";
}

sub vcl_recv {
        if (server.ip == "195.159.7.10") {
                set req.backend = krusty;
        } elsif (req.http.host ~ "^(www(2)?\.)?db24\.no$") {
                        set req.backend = ned;
                } elsif (req.http.host ~ "^(www(2)?\.)?dinebeslutninger\.no$") {
                        set req.backend = ned;
                } elsif (req.http.host ~ "^(www(2)?\.)?dfs\.no$") {
                        set req.backend = todd;
                } elsif (req.http.host ~ "^(www(2)?\.)?utdanningsmagasinet\.no$") {
                        set req.backend = doris;
                } elsif (req.http.host ~ "^(www(2)?\.)?karrieremagasinet\.no$") {
                        set req.backend = doris;
                } elsif (req.http.host ~ "^(www(2)?\.)?bestwestern\.no$") {
                        set req.backend = doris;
                } elsif (req.http.host ~ "^(www(2)?\.)?pensjonistforbundet\.no$") {
                        set req.backend = doris;
                } elsif (req.http.host ~ "^(www(2)?\.)?eldrerad\.no$") {
                        set req.backend = doris;
                } elsif (req.http.host ~ "^(www(2)?\.)?reiseplaneten\.no$") {
                        set req.backend = patty;
                } elsif (req.http.host ~ "^(www(2)?\.)?hr-manager\.net$") {
                        set req.backend = doris;
                } elsif (req.http.host ~ "^(www(2)?\.)?kaleidoskopet\.no$") {
                        set req.backend = doris;
                } else {
                        error 404 "You requested a document from an unknown virtual host.";
        }

        if (req.request == "POST") {
                pipe;
        }

        if (req.http.Pragma ~ "no-cache" || req.http.Cache-Control ~ "no-cache") {
                pass;
        }

        if(req.url == "/admin/.*$" || req.url == "/admin$")
        {
                pass;
        }


        if (req.request == "PURGE") {
                if (!client.ip ~ purge) {
                        error 405 "Not allowed.";
                }
                lookup;
        }

        if (req.request == "GET" && req.http.cookie) {
                lookup;
        }

}

sub vcl_hit {
        if (!obj.cacheable) {
               pass;
        }

        if (req.request == "PURGE") {
                set obj.ttl = 0s;
                error 200 "Purged.";
        }
}

sub vcl_fetch {
        if (obj.ttl < 1200s) {
                set obj.ttl = 1200s;
        }
        if (resp.http.Pragma ~ "no-cache" || resp.http.Cache-Control ~ "no-cache") {
                set obj.ttl = 0s;
                pass;
        }

}

sub vcl_miss {
        if (req.request == "PURGE") {
                error 404 "Not in cache.";
        }
}