caching.stpl 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_ssl_server_name on;
  24. proxy_ssl_name $host;
  25. proxy_pass https://%ip%:%web_ssl_port%;
  26. proxy_cache %domain%;
  27. proxy_cache_valid 200 5m;
  28. proxy_cache_valid 301 302 10m;
  29. proxy_cache_valid 404 10m;
  30. proxy_cache_bypass $no_cache $cookie_session $http_x_update;
  31. proxy_no_cache $no_cache;
  32. set $no_cache 0;
  33. if ($request_uri ~* "/wp-admin/|/wp-json/|wp-.*.php|xmlrpc.php|/store.*|/cart.*|/my-account.*|/checkout.*|/user/|/admin/|/administrator/|/manager/|index.php") {
  34. set $no_cache 1;
  35. }
  36. 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") {
  37. set $no_cache 1;
  38. }
  39. if ($http_cookie ~ SESS) {
  40. set $no_cache 1;
  41. }
  42. location ~* ^.+\.(%proxy_extensions%)$ {
  43. try_files $uri @fallback;
  44. root %sdocroot%;
  45. access_log /var/log/%web_system%/domains/%domain%.log combined;
  46. access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
  47. expires max;
  48. proxy_cache off;
  49. }
  50. }
  51. location @fallback {
  52. proxy_ssl_server_name on;
  53. proxy_ssl_name $host;
  54. proxy_pass https://%ip%:%web_ssl_port%;
  55. }
  56. location /error/ {
  57. alias %home%/%user%/web/%domain%/document_errors/;
  58. }
  59. proxy_hide_header Upgrade;
  60. include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
  61. }