caching.tpl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. error_log /var/log/%web_system%/domains/%domain%.error.log error;
  10. include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
  11. location ~ /\.(?!well-known\/|file) {
  12. deny all;
  13. return 404;
  14. }
  15. location / {
  16. proxy_pass http://%ip%:%web_port%;
  17. proxy_cache %domain%;
  18. proxy_cache_valid 200 5m;
  19. proxy_cache_valid 301 302 10m;
  20. proxy_cache_valid 404 10m;
  21. proxy_cache_bypass $no_cache $cookie_session $http_x_update;
  22. proxy_no_cache $no_cache;
  23. set $no_cache 0;
  24. if ($request_uri ~* "/wp-admin/|/wp-json/|wp-.*.php|xmlrpc.php|/store.*|/cart.*|/my-account.*|/checkout.*|/user/|/admin/|/administrator/|/manager/|index.php") {
  25. set $no_cache 1;
  26. }
  27. 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") {
  28. set $no_cache 1;
  29. }
  30. if ($http_cookie ~ SESS) {
  31. set $no_cache 1;
  32. }
  33. location ~* ^.+\.(%proxy_extensions%)$ {
  34. try_files $uri @fallback;
  35. root %docroot%;
  36. access_log /var/log/%web_system%/domains/%domain%.log combined;
  37. access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
  38. expires max;
  39. proxy_cache off;
  40. }
  41. }
  42. location @fallback {
  43. proxy_pass http://%ip%:%web_port%;
  44. }
  45. location /error/ {
  46. alias %home%/%user%/web/%domain%/document_errors/;
  47. }
  48. include %home%/%user%/conf/web/%domain%/nginx.conf_*;
  49. }