caching.stpl 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #=======================================================================#
  2. # Default Web Domain Template #
  3. # DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
  4. #=======================================================================#
  5. server {
  6. listen %ip%:%proxy_ssl_port% ssl http2;
  7. server_name %domain_idn% %alias_idn%;
  8. ssl_certificate %ssl_pem%;
  9. ssl_certificate_key %ssl_key%;
  10. ssl_stapling on;
  11. ssl_stapling_verify on;
  12. error_log /var/log/%web_system%/domains/%domain%.error.log error;
  13. include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
  14. location / {
  15. proxy_pass https://%ip%:%web_ssl_port%;
  16. proxy_cache %domain%;
  17. proxy_cache_valid 200 5m;
  18. proxy_cache_valid 301 302 10m;
  19. proxy_cache_valid 404 10m;
  20. proxy_cache_bypass $no_cache $cookie_session $http_x_update;
  21. proxy_no_cache $no_cache;
  22. set $no_cache 0;
  23. if ($request_uri ~* "/wp-admin/|wp-.*.php|xmlrpc.php|/store.*|/cart.*|/my-account.*|/checkout.*|/user/|/admin/|/administrator/|/manager/|index.php") {
  24. set $no_cache 1;
  25. }
  26. 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") {
  27. set $no_cache 1;
  28. }
  29. if ($http_cookie ~ SESS) {
  30. set $no_cache 1;
  31. }
  32. location ~* ^.+\.(%proxy_extensions%)$ {
  33. proxy_cache off;
  34. root %sdocroot%;
  35. access_log /var/log/%web_system%/domains/%domain%.log combined;
  36. access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
  37. expires max;
  38. try_files $uri @fallback;
  39. }
  40. }
  41. location /error/ {
  42. alias %home%/%user%/web/%domain%/document_errors/;
  43. }
  44. location @fallback {
  45. proxy_pass https://%ip%:%web_ssl_port%;
  46. }
  47. location ~ /\.ht {return 404;}
  48. location ~ /\.svn/ {return 404;}
  49. location ~ /\.git/ {return 404;}
  50. location ~ /\.hg/ {return 404;}
  51. location ~ /\.bzr/ {return 404;}
  52. proxy_hide_header Upgrade;
  53. include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
  54. }