Guest User

Untitled

a guest
Sep 24th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. # This is a basic VCL configuration file for varnish. See the vcl(7)
  2. #man page for details on VCL syntax and semantics.
  3. #
  4. #Default backend definition. Set this to point to your content
  5. #server.
  6. #
  7. backend default {
  8. .host = "xxxxx"
  9. .port = "80";
  10. }
  11.  
  12.  
  13. acl purge {
  14. ip range
  15. }
  16.  
  17. sub vcl_hash {
  18. hash_data(req.http.cookie);
  19. return (hash);
  20. }
  21.  
  22. sub vcl_recv {
  23. if (req.restarts == 0) {
  24. if (req.http.X-forwarded-For) {
  25. set req.http.X-Forwarded-For =
  26. req.http.X-Forwarded-For + ", " + client.ip;
  27. } else {
  28. set req.http.X-Forwarded-For = client.ip;
  29. }
  30. }
  31.  
  32. if (req.request == "PURGE") {
  33. if (!client.ip ~ purge) {
  34. error 405 "Not allowed.";
  35. }
  36. return(lookup);
  37. }
  38. }
  39.  
  40. sub vcl_deliver {
  41. if (obj.hits > 0) {
  42. set resp.http.X-Cache = "HIT";
  43. } else {
  44. set resp.http.X-Cache = "MISS";
  45. }
  46. }
  47.  
  48. sub vcl_hit {
  49. if (req.request == "PURGE") {
  50. set obj.ttl = 0s;
  51. error 200 "Purged.";
  52. }
  53. }
  54. sub vcl_miss {
  55. if (req.request == "PURGE") {
  56. error 404 "Not in cache.";
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment