Advertisement
Guest User

Untitled

a guest
Feb 10th, 2015
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. backend default {
  2. .host = "127.0.0.1";
  3. .port = "8080";
  4. }
  5. acl purge {
  6. "localhost";
  7. }
  8. sub vcl_recv {
  9.  
  10. # Modify HTTP X-Forwarded-For header.
  11. # This will replace Varnish's IP with actual client's.
  12. remove req.http.X-Forwarded-For;
  13. set req.http.X-Forwarded-For = client.ip;
  14.  
  15. # Check the incoming request type is "PURGE", not "GET" or "POST"
  16. if (req.request == "PURGE") {
  17. # Check if the ip coresponds with the acl purge
  18. if (!client.ip ~ purge) {
  19. # Return error code 405 (Forbidden) when not
  20. error 405 "Not allowed.";
  21. }
  22. return (lookup);
  23. }
  24. # Get rid of progress.js query params
  25. if (req.url ~ "^/misc/progress\.js\?[0-9]+$") {
  26. set req.url = "/misc/progress.js";
  27. }
  28.  
  29.  
  30. # Do not cache these paths.
  31. if (req.url ~ "^/status\.php$" ||
  32. req.url ~ "^/update\.php" ||
  33. req.url ~ "^/install\.php" ||
  34. req.url ~ "^/admin" ||
  35. req.url ~ "^/admin/.*$" ||
  36. req.url ~ "^/user" ||
  37. req.url ~ "^/user/.*$" ||
  38. req.url ~ "^/users/.*$" ||
  39. req.url ~ "^/info/.*$" ||
  40. req.url ~ "^/flag/.*$" ||
  41. req.url ~ "^.*/ajax/.*$" ||
  42. req.url ~ "^.*/ahah/.*$") {
  43. return (pass);
  44. }
  45.  
  46.  
  47. # Pipe these paths directly to Apache for streaming.
  48. if (req.url ~ "^/admin/content/backup_migrate/export") {
  49. return (pipe);
  50. }
  51.  
  52. if (req.http.Cookie)
  53. {
  54. set req.http.Cookie = ";" req.http.Cookie;
  55. set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
  56. set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-zA-Z0-9]*)=", "; \1=");
  57. set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
  58. set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
  59.  
  60. if (req.http.Cookie == "") {
  61. remove req.http.Cookie;
  62. }
  63. }
  64. # if (req.url ~ "^/$") {
  65. # unset req.http.cookie;
  66. # }
  67.  
  68. # Cache static content of themes.
  69. if (req.url ~ ".(css|js|png|gif|jp(e)?g)")
  70. {
  71. unset req.http.cookie;
  72. }
  73.  
  74. return(lookup);
  75. }
  76. sub vcl_hit {
  77. if (req.request == "PURGE") {
  78. set obj.ttl = 0s;
  79. error 200 "Purged.";
  80. }
  81. }
  82. sub vcl_fetch {
  83. # if (req.url ~ "^/$") {
  84. # unset beresp.http.set-cookie;
  85. # }
  86. # if (!(req.url ~ "wp-(login|admin)")) {
  87. # unset beresp.http.set-cookie;
  88. # }
  89. }
  90.  
  91. # Set a header to track a cache HIT/MISS.
  92. sub vcl_deliver {
  93. if (obj.hits > 0) {
  94. set resp.http.X-Varnish-Cache = "HIT";
  95. }
  96. else {
  97. set resp.http.X-Varnish-Cache = "MISS";
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement