Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is a basic VCL configuration file for varnish. See the vcl(7)
- #man page for details on VCL syntax and semantics.
- #
- #Default backend definition. Set this to point to your content
- #server.
- #
- backend default {
- .host = "xxxxx"
- .port = "80";
- }
- acl purge {
- ip range
- }
- sub vcl_hash {
- hash_data(req.http.cookie);
- return (hash);
- }
- sub vcl_recv {
- if (req.restarts == 0) {
- if (req.http.X-forwarded-For) {
- set req.http.X-Forwarded-For =
- req.http.X-Forwarded-For + ", " + client.ip;
- } else {
- set req.http.X-Forwarded-For = client.ip;
- }
- }
- if (req.request == "PURGE") {
- if (!client.ip ~ purge) {
- error 405 "Not allowed.";
- }
- return(lookup);
- }
- }
- sub vcl_deliver {
- if (obj.hits > 0) {
- set resp.http.X-Cache = "HIT";
- } else {
- set resp.http.X-Cache = "MISS";
- }
- }
- sub vcl_hit {
- if (req.request == "PURGE") {
- set obj.ttl = 0s;
- error 200 "Purged.";
- }
- }
- sub vcl_miss {
- if (req.request == "PURGE") {
- error 404 "Not in cache.";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment