Example

  1. global
  2. nuster cache on data-size 100m
  3. nuster nosql on data-size 100m
  4. master-worker # v3
  5. # daemon
  6. # debug
  7. defaults
  8. retries 3
  9. option redispatch
  10. timeout client 30s
  11. timeout connect 30s
  12. timeout server 30s
  13. frontend web1
  14. bind *:8080
  15. mode http
  16. acl pathPost path /search
  17. use_backend app1a if pathPost
  18. default_backend app1b
  19. backend app1a
  20. balance roundrobin
  21. # mode must be http
  22. mode http
  23. # http-buffer-request must be enabled to cache post request
  24. option http-buffer-request
  25. acl pathPost path /search
  26. # enable cache for this proxy
  27. nuster cache
  28. # cache /search for 120 seconds. Only works when POST/PUT
  29. nuster rule rpost key method.scheme.host.uri.body ttl 120 if pathPost
  30. server s1 10.0.0.10:8080
  31. backend app1b
  32. balance roundrobin
  33. mode http
  34. nuster cache on
  35. # cache /a.jpg, not expire
  36. acl pathA path /a.jpg
  37. nuster rule r1 ttl 0 if pathA
  38. # cache /mypage, key contains cookie[userId], so it will be cached per user
  39. acl pathB path /mypage
  40. nuster rule r2 key method.scheme.host.path.delimiter.query.cookie_userId ttl 60 if pathB
  41. # cache /a.html if response's header[cache] is yes
  42. http-request set-var(txn.pathC) path
  43. acl pathC var(txn.pathC) -m str /a.html
  44. acl resHdrCache1 res.hdr(cache) yes
  45. nuster rule r3 if pathC resHdrCache1
  46. # cache /heavy for 100 seconds if be_conn greater than 10
  47. acl heavypage path /heavy
  48. acl tooFast be_conn ge 100
  49. nuster rule heavy ttl 100 if heavypage tooFast
  50. # cache all if response's header[asdf] is fdsa
  51. acl resHdrCache2 res.hdr(asdf) fdsa
  52. nuster rule resCache ttl 0 if resHdrCache1
  53. server s1 10.0.0.10:8080
  54. frontend web2
  55. bind *:8081
  56. mode http
  57. default_backend app2
  58. backend app2
  59. balance roundrobin
  60. mode http
  61. # disable cache on this proxy
  62. nuster cache off
  63. nuster rule all
  64. server s2 10.0.0.11:8080
  65. frontend nosql_fe
  66. bind *:9090
  67. default_backend nosql_be
  68. backend nosql_be
  69. nuster nosql on
  70. nuster rule r1 ttl 3600