caching.tpl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #=========================================================================#
  2. # Default Web Domain Template #
  3. # DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
  4. # https://hestiacp.com/docs/server-administration/web-templates.html #
  5. #=========================================================================#
  6. server {
  7. listen %ip%:%proxy_port%;
  8. server_name %domain_idn% %alias_idn%;
  9. include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
  10. location / {
  11. proxy_pass http://%ip%:%web_port%;
  12. proxy_cache %domain%;
  13. proxy_cache_valid 200 5m;
  14. proxy_cache_valid 301 302 10m;
  15. proxy_cache_valid 404 10m;
  16. proxy_cache_bypass $no_cache $cookie_session $http_x_update;
  17. proxy_no_cache $no_cache;
  18. set $no_cache 0;
  19. if ($request_uri ~* "/wp-admin/|/wp-json/|wp-.*.php|xmlrpc.php|/store.*|/cart.*|/my-account.*|/checkout.*|/user/|/admin/|/administrator/|/manager/|index.php") {
  20. set $no_cache 1;
  21. }
  22. if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart|woocommerce_cart_hash|PHPSESSID") {
  23. set $no_cache 1;
  24. }
  25. if ($http_cookie ~ SESS) {
  26. set $no_cache 1;
  27. }
  28. location ~* ^.+\.(%proxy_extensions%)$ {
  29. proxy_cache off;
  30. root %docroot%;
  31. access_log /var/log/%web_system%/domains/%domain%.log combined;
  32. access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
  33. expires max;
  34. try_files $uri @fallback;
  35. }
  36. }
  37. location /error/ {
  38. alias %home%/%user%/web/%domain%/document_errors/;
  39. }
  40. location @fallback {
  41. proxy_pass http://%ip%:%web_port%;
  42. }
  43. location ~ /\.(?!well-known\/|file) {
  44. deny all;
  45. return 404;
  46. }
  47. include %home%/%user%/conf/web/%domain%/nginx.conf_*;
  48. }