Advertisement
Guest User

Untitled

a guest
Oct 1st, 2012
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 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. .first_byte_timeout = 6000s;
  11. }
  12. acl purge {
  13. "localhost";
  14. "127.0.0.1";
  15. }
  16. sub vcl_recv {
  17. # Add a unique header containing the client address
  18. remove req.http.X-Forwarded-For;
  19. set req.http.X-Forwarded-For = client.ip;
  20. # Let's make sure we aren't compressing already compressed formats.
  21. if (req.http.Accept-Encoding) {
  22. if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|mp3|mp4|m4v)(\?.*|)$") {
  23. remove req.http.Accept-Encoding;
  24. } elsif (req.http.Accept-Encoding ~ "gzip") {
  25. set req.http.Accept-Encoding = "gzip";
  26. } elsif (req.http.Accept-Encoding ~ "deflate") {
  27. set req.http.Accept-Encoding = "deflate";
  28. } else {
  29. remove req.http.Accept-Encoding;
  30. }
  31. }
  32. if (req.request == "PURGE") {
  33. if (!client.ip ~ purge) {
  34. error 405 "Not allowed.";
  35. }
  36. return(lookup);
  37. }
  38. if (req.url ~ "^/$") {
  39. unset req.http.cookie;
  40. }
  41. }
  42. sub vcl_hit {
  43. if (req.request == "PURGE") {
  44. set obj.ttl = 0s;
  45. error 200 "Purged.";
  46. }
  47. }
  48. sub vcl_miss {
  49. if (req.request == "PURGE") {
  50. error 404 "Not in cache.";
  51. }
  52. if (!(req.url ~ "wp-(login|admin)")) {
  53. unset req.http.cookie;
  54. }
  55. if (req.url ~ "^/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.|)$") {
  56. unset req.http.cookie;
  57. set req.url = regsub(req.url, "\?.$", "");
  58. }
  59. if (req.url ~ "^/$") {
  60. unset req.http.cookie;
  61. }
  62. }
  63. sub vcl_fetch {
  64. if (req.url ~ "^/$") {
  65. unset beresp.http.set-cookie;
  66. }
  67. if (!(req.url ~ "wp-(login|admin)")) {
  68. unset beresp.http.set-cookie;
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement