caching.stpl 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_ssl_port% ssl;
  8. server_name %domain_idn% %alias_idn%;
  9. error_log /var/log/%web_system%/domains/%domain%.error.log error;
  10. ssl_certificate %ssl_pem%;
  11. ssl_certificate_key %ssl_key%;
  12. ssl_stapling on;
  13. ssl_stapling_verify on;
  14. # TLS 1.3 0-RTT anti-replay
  15. if ($anti_replay = 307) { return 307 https://$host$request_uri; }
  16. if ($anti_replay = 425) { return 425; }
  17. include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
  18. location ~ /\.(?!well-known\/|file) {
  19. deny all;
  20. return 404;
  21. }
  22. location / {
  23. proxy_pass https://%ip%:%web_ssl_port%;
  24. proxy_cache %domain%;
  25. proxy_cache_valid 200 5m;
  26. proxy_cache_valid 301 302 10m;
  27. proxy_cache_valid 404 10m;
  28. proxy_cache_bypass $no_cache $cookie_session $http_x_update;
  29. proxy_no_cache $no_cache;
  30. set $no_cache 0;
  31. if ($request_uri ~* "/wp-admin/|/wp-json/|wp-.*.php|xmlrpc.php|/store.*|/cart.*|/my-account.*|/checkout.*|/user/|/admin/|/administrator/|/manager/|index.php") {
  32. set $no_cache 1;
  33. }
  34. 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") {
  35. set $no_cache 1;
  36. }
  37. if ($http_cookie ~ SESS) {
  38. set $no_cache 1;
  39. }
  40. location ~* ^.+\.(%proxy_extensions%)$ {
  41. try_files $uri @fallback;
  42. root %sdocroot%;
  43. access_log /var/log/%web_system%/domains/%domain%.log combined;
  44. access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
  45. expires max;
  46. proxy_cache off;
  47. }
  48. }
  49. location @fallback {
  50. proxy_pass https://%ip%:%web_ssl_port%;
  51. }
  52. location /error/ {
  53. alias %home%/%user%/web/%domain%/document_errors/;
  54. }
  55. proxy_hide_header Upgrade;
  56. include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
  57. }