vcl 4.1; import directors; backend cvmfs_stratum_one_cern_ch_1 { .host = "128.142.194.62"; .port = "80"; } backend cvmfs_stratum_one_cern_ch_2 { .host = "128.142.194.68"; .port = "80"; } backend cvmfs_stratum_one_cern_ch_3 { .host = "128.142.194.109"; .port = "80"; } backend cvmfs_stratum_one_cern_ch_4 { .host = "128.142.194.113"; .port = "80"; } #aws-eu-west-s1-sync.eessi.science backend eessi_aws_1 { .host = "172.67.178.138"; .port = "80"; } backend eessi_aws_2 { .host = "104.21.43.111"; .port = "80"; } sub vcl_init { new cvmfsconfig = directors.random(); cvmfsconfig.add_backend(cvmfs_stratum_one_cern_ch_1, 1.0); cvmfsconfig.add_backend(cvmfs_stratum_one_cern_ch_2, 1.0); cvmfsconfig.add_backend(cvmfs_stratum_one_cern_ch_3, 1.0); cvmfsconfig.add_backend(cvmfs_stratum_one_cern_ch_4, 1.0); new eessi = directors.round_robin(); eessi.add_backend(eessi_aws_1); eessi.add_backend(eessi_aws_2); } sub vcl_recv { unset req.http.CVMFS-Mutable; unset req.http.CVMFS-Immutable; unset req.http.CVMFS-Metadata; unset req.http.CVMFS-Published; unset req.http.CVMFS-Whitelist; unset req.http.CVMFS-Dirtab; unset req.http.CVMFS-Reflog; unset req.http.CVMFS-Data; unset req.http.CVMFS-Catalog; unset req.http.CVMFS-History; unset req.http.CVMFS-Partial; unset req.http.CVMFS-Temporary; unset req.http.CVMFS-Certificate; unset req.http.CVMFS-Metainfo; unset req.http.CVMFS-External; set req.http.CVMFS-Status = "NONE"; # CVMFS objects if (req.url ~ "\/\.cvmfs[0-9a-z]*$") { set req.http.CVMFS-Mutable = "true"; set req.http.CVMFS-Metadata = "true"; if (req.url ~ "\/\.cvmfspublished$") { set req.http.CVMFS-Published = "true"; } else if (req.url ~ "\/\.cvmfswhitelist$") { set req.http.CVMFS-Whitelist = "true"; } else if (req.url ~ "\/\.cvmfsdirtab$") { set req.http.CVMFS-Dirtab = "true"; } else if (req.url ~ "\/\.cvmfsreflog$") { set req.http.CVMFS-Reflog = "true"; } } else if (req.url ~ "\/data\/[0-9a-z]{2}\/[a-z0-9]{38}[A-Z]?$") { set req.http.CVMFS-Immutable = "true"; set req.http.CVMFS-Data = "true"; if (req.url ~ "[A-Z]$") { set req.http.CVMFS-Metadata = "true"; if (req.url ~ "C$") { set req.http.CVMFS-Catalog = "true"; } else if (req.url ~ "H$") { set req.http.CVMFS-History = "true"; } else if (req.url ~ "P$") { set req.http.CVMFS-Partial = "true"; } else if (req.url ~ "T$") { set req.http.CVMFS-Temporary = "true"; } else if (req.url ~ "X$") { set req.http.CVMFS-Certificate = "true"; } else if (req.url ~ "M$") { set req.http.CVMFS-Metainfo = "true"; } } } if (!req.http.CVMFS-Mutable && !req.http.CVMFS-Immutable) { set req.http.CVMFS-External = "true"; } if (req.url ~ "cvmfs-config") { set req.backend_hint = cvmfsconfig.backend(); } else { set req.backend_hint = eessi.backend(); } if (req.http.Cache-Control ~ "no-cache") { return (pass); } if (req.method == "GET" || req.method == "HEAD") { return (hash); } return (pass); } sub vcl_hash { hash_data(req.url); return (lookup); } sub vcl_hit { set req.http.CVMFS-Status = "HIT"; } sub vcl_miss { set req.http.CVMFS-Status = "MISS"; } sub vcl_pass { set req.http.CVMFS-Status = "PASS"; } sub vcl_backend_response { if (beresp.status == 200) { if (bereq.http.CVMFS-Mutable) { set beresp.ttl = 2s; set beresp.grace = 3s; set beresp.keep = 1y; } else if (bereq.http.CVMFS-Immutable || bereq.http.CVMFS-External) { set beresp.ttl = 30d; set beresp.grace = 7d; set beresp.keep = 1y; } } else { set beresp.ttl = 1s; set beresp.grace = 0s; } } sub vcl_backend_error { if (beresp.status == 503) { return (retry); } } sub vcl_deliver { set resp.http.CVMFS-Varnish = "eessi.vcl"; if (resp.http.CVMFS-Status) { set resp.http.CVMFS-Status = resp.http.CVMFS-Status + ", "; } if (req.http.CVMFS-Status ~ "HIT|MISS") { set resp.http.CVMFS-Status = resp.http.CVMFS-Status + server.identity + " " + req.http.CVMFS-Status + "(" + obj.hits + ")"; } else { set resp.http.CVMFS-Status = resp.http.CVMFS-Status + server.identity + " " + req.http.CVMFS-Status; } if (obj.uncacheable) { set resp.http.CVMFS-Uncacheable = "true"; } else { set resp.http.CVMFS-TTL = obj.ttl; } }