revensanchez

varnish vcl config

Jul 17th, 2013
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 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 = "127.0.0.1";
  9. .port = "8080";
  10. }
  11. acl purge {
  12. "localhost";
  13. }
  14.  
  15. sub vcl_recv {
  16. if (req.request == "PURGE") {
  17. if (!client.ip ~ purge) {
  18. error 405 "Not allowed.";
  19. }
  20. return(lookup);
  21. }
  22. if (req.url ~ "^/$") {
  23. unset req.http.cookie;
  24. }
  25. }
  26. sub vcl_hit {
  27. if (req.request == "PURGE") {
  28. set obj.ttl = 0s;
  29. error 200 "Purged.";
  30. }
  31. }
  32. sub vcl_miss {
  33. if (req.request == "PURGE") {
  34. error 404 "Not in cache.";
  35. }
  36. if (!(req.url ~ "wp-(login|admin)")) {
  37. unset req.http.cookie;
  38. }
  39. if (req.url ~ "^/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.|)$") {
  40. unset req.http.cookie;
  41. set req.url = regsub(req.url, "\?.$", "");
  42. }
  43. if (req.url ~ "^/$") {
  44. unset req.http.cookie;
  45. }
  46. }
  47. sub vcl_fetch {
  48. if (req.url ~ "^/$") {
  49. unset beresp.http.set-cookie;
  50. }
  51. if (!(req.url ~ "wp-(login|admin)")) {
  52. unset beresp.http.set-cookie;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment