imcrazytwkr

Ghost on Varnish

Jan 11th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #
  2. # Varnish VCL file for Ghost blogging platform.
  3. # http://ghost.org/
  4. #
  5. # Written for Ghost v0.3.0.
  6. # Adapted for Ghost v0.5.2 by twkr.
  7. #
  8. # This is a low-hanging-fruit type of VCL. TTL of objects are overridden to 2
  9. # minutes, and everything below /ghost/ is pass()-ed so the user sessions
  10. # work.
  11. #
  12. # Author: Lasse Karstensen <[email protected]>, September 2013.
  13.  
  14.  
  15. backend default {
  16. .host = "localhost";
  17. .port = "8081";
  18. }
  19.  
  20.  
  21. sub vcl_recv {
  22. # If the client uses shift-F5, get (and cache) a fresh copy. Nice for systems without content invalidation. Big sites will want to disable this.
  23. if (req.http.cache-control ~ "no-cache") {
  24. set req.hash_always_miss = true;
  25. }
  26.  
  27. set req.http.x-pass = "false";
  28. # TODO: I haven't seen any urls for logging access. When the analytics parts of ghost are done, this needs to be added in the exception list below.
  29. if (req.url ~ "^/(api|signout)") {
  30. set req.http.x-pass = "true";
  31. } elseif (req.url ~ "^/ghost" && (req.url !~ "^/ghost/(img|css|fonts)")) {
  32. set req.http.x-pass = "true";
  33. }
  34.  
  35. if (req.http.x-pass == "true") {
  36. return(pass);
  37. }
  38. unset req.http.cookie;
  39. }
  40.  
  41. # Only modify cookies/ttl outside of the management interface.
  42. sub vcl_fetch {
  43. if (req.http.x-pass != "true") {
  44. unset beresp.http.set-cookie;
  45. if (beresp.status < 500 && beresp.ttl == 0s) {
  46. set beresp.ttl = 2m;
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment