Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. backend apache {
  2. .host = "127.0.0.1";
  3. .port = "8080";
  4. .first_byte_timeout = 1200s;
  5. }
  6.  
  7. acl purge {
  8. "localhost";
  9. "127.0.0.1";
  10. }
  11.  
  12. sub vcl_recv {
  13.  
  14. set req.http.X-Forwarded-For = client.ip;
  15.  
  16. if (req.request != "GET" ) {
  17. return(pipe);
  18. }
  19.  
  20. // Strip cookies and normalize accept-encoding for static files and try to cache:
  21. if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf)$") {
  22. ### parse accept encoding rulesets to normalize
  23. if (req.http.Accept-Encoding) {
  24. if (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. # unkown algorithm
  30. remove req.http.Accept-Encoding;
  31. }
  32. }
  33.  
  34. unset req.http.Cookie;
  35. return(lookup);
  36. }
  37.  
  38. if (req.request == "PURGE") {
  39. if (!client.ip ~ purge) {
  40. error 405 "Not allowed.";
  41. }
  42. purge("req.url ~ " req.url " && req.http.host == " req.http.host);
  43. error 200 "Purged.";
  44. }
  45.  
  46. # pass everything else
  47. return (pass);
  48. }
  49.  
  50. sub vcl_pipe {
  51. /* Force the connection to be closed afterwards so subsequent reqs don't use pipe */
  52. set bereq.http.connection = "close";
  53. }
  54.  
  55. sub vcl_fetch {
  56.  
  57. // Strip cookies for static files:
  58. if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf)$") {
  59. unset beresp.http.set-cookie;
  60. if ( beresp.ttl < 1s ) {
  61. set beresp.ttl = 300s;
  62. }
  63.  
  64. //if (beresp.status == 302 && req.url ~ "var/assets"){
  65. // return(pass);
  66. //}
  67.  
  68. if (beresp.status > 299){
  69. return(pass);
  70. }
  71. }
  72. }
  73.  
  74. sub vcl_deliver {
  75. if (obj.hits > 0) {
  76. set resp.http.X-Cache = "HIT";
  77. } else {
  78. set resp.http.X-Cache = "MISS";
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement