Browse Source

[Feature] Nginx Fast CGI Cache support (#1378)

* Revert "Revert "Merge branch 'cmstew-cache-improvements' into staging/fixes""

This reverts commit d323e9972c69bef151c8d86cc0ac2cf69c362b99.

* Fixes duplicate key_zones

* Add webui support for nginx-cache feature

* Add “Delete” cache support

* Fix minor issues  update layout

* - Fixed issues with javascript
- Allow removal of cache via command line (Please not not optimal preformance)
- Added support for debugging cache prefomance via debug flag.

* Update templates + js

* Update all templates to include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;

* - Added update support 
- Delete cache

* Update permsions + changed button + Allowed “users” level to do the same

* Delete cache script

* Add “info” icon for more information

* Renamed v-delete-web-domain-nginx-cache to v-purge-xxx

* Update PHP script

* Updated upgrade script to 1.3.3
Jaap Marcus 5 years ago
parent
commit
b4fabfcb19
63 changed files with 474 additions and 47 deletions
  1. 110 0
      bin/v-add-web-domain-fast-cgi-cache
  2. 77 0
      bin/v-add-web-domain-ssl-preset
  3. 1 0
      bin/v-list-web-domain
  4. 67 0
      bin/v-purge-web-domain-nginx-cache
  5. 8 0
      install/deb/nginx/nginx.conf
  6. 1 1
      install/deb/templates/web/nginx/caching.stpl
  7. 1 1
      install/deb/templates/web/nginx/caching.tpl
  8. 1 0
      install/deb/templates/web/nginx/php-fpm/cms_made_simple.stpl
  9. 1 0
      install/deb/templates/web/nginx/php-fpm/cms_made_simple.tpl
  10. 2 1
      install/deb/templates/web/nginx/php-fpm/codeigniter2.stpl
  11. 2 1
      install/deb/templates/web/nginx/php-fpm/codeigniter2.tpl
  12. 1 0
      install/deb/templates/web/nginx/php-fpm/codeigniter3.stpl
  13. 2 0
      install/deb/templates/web/nginx/php-fpm/codeigniter3.tpl
  14. 1 0
      install/deb/templates/web/nginx/php-fpm/datalife_engine.stpl
  15. 1 0
      install/deb/templates/web/nginx/php-fpm/datalife_engine.tpl
  16. 1 0
      install/deb/templates/web/nginx/php-fpm/default.stpl
  17. 1 0
      install/deb/templates/web/nginx/php-fpm/default.tpl
  18. 1 0
      install/deb/templates/web/nginx/php-fpm/dokuwiki.stpl
  19. 1 0
      install/deb/templates/web/nginx/php-fpm/dokuwiki.tpl
  20. 2 1
      install/deb/templates/web/nginx/php-fpm/drupal-composer.stpl
  21. 2 1
      install/deb/templates/web/nginx/php-fpm/drupal-composer.tpl
  22. 2 1
      install/deb/templates/web/nginx/php-fpm/drupal-social.stpl
  23. 2 1
      install/deb/templates/web/nginx/php-fpm/drupal-social.tpl
  24. 2 1
      install/deb/templates/web/nginx/php-fpm/drupal6.stpl
  25. 2 1
      install/deb/templates/web/nginx/php-fpm/drupal6.tpl
  26. 2 1
      install/deb/templates/web/nginx/php-fpm/drupal7.stpl
  27. 2 1
      install/deb/templates/web/nginx/php-fpm/drupal7.tpl
  28. 1 0
      install/deb/templates/web/nginx/php-fpm/drupal8.stpl
  29. 1 0
      install/deb/templates/web/nginx/php-fpm/drupal8.tpl
  30. 2 1
      install/deb/templates/web/nginx/php-fpm/joomla.stpl
  31. 2 1
      install/deb/templates/web/nginx/php-fpm/joomla.tpl
  32. 2 1
      install/deb/templates/web/nginx/php-fpm/laravel.stpl
  33. 2 1
      install/deb/templates/web/nginx/php-fpm/laravel.tpl
  34. 6 3
      install/deb/templates/web/nginx/php-fpm/magento.stpl
  35. 6 3
      install/deb/templates/web/nginx/php-fpm/magento.tpl
  36. 1 0
      install/deb/templates/web/nginx/php-fpm/modx.stpl
  37. 1 0
      install/deb/templates/web/nginx/php-fpm/modx.tpl
  38. 2 1
      install/deb/templates/web/nginx/php-fpm/moodle.stpl
  39. 2 1
      install/deb/templates/web/nginx/php-fpm/moodle.tpl
  40. 2 1
      install/deb/templates/web/nginx/php-fpm/opencart.stpl
  41. 2 1
      install/deb/templates/web/nginx/php-fpm/opencart.tpl
  42. 2 0
      install/deb/templates/web/nginx/php-fpm/owncloud.stpl
  43. 2 0
      install/deb/templates/web/nginx/php-fpm/owncloud.tpl
  44. 2 1
      install/deb/templates/web/nginx/php-fpm/piwik.stpl
  45. 2 1
      install/deb/templates/web/nginx/php-fpm/piwik.tpl
  46. 1 0
      install/deb/templates/web/nginx/php-fpm/prestashop.stpl
  47. 1 0
      install/deb/templates/web/nginx/php-fpm/prestashop.tpl
  48. 2 1
      install/deb/templates/web/nginx/php-fpm/pyrocms.stpl
  49. 2 1
      install/deb/templates/web/nginx/php-fpm/pyrocms.tpl
  50. 1 0
      install/deb/templates/web/nginx/php-fpm/sendy.stpl
  51. 1 0
      install/deb/templates/web/nginx/php-fpm/sendy.tpl
  52. 1 0
      install/deb/templates/web/nginx/php-fpm/thunder.stpl
  53. 1 0
      install/deb/templates/web/nginx/php-fpm/thunder.tpl
  54. 2 1
      install/deb/templates/web/nginx/php-fpm/wordpress.stpl
  55. 2 1
      install/deb/templates/web/nginx/php-fpm/wordpress.tpl
  56. 0 1
      install/upgrade/versions/1.3.2.sh
  57. 22 0
      install/upgrade/versions/1.3.3.sh
  58. 27 0
      web/delete/web/cache/index.php
  59. 14 0
      web/edit/web/index.php
  60. 3 1
      web/js/pages/add_web.js
  61. 20 0
      web/js/pages/edit_web.js
  62. 19 0
      web/templates/admin/edit_web.html
  63. 19 13
      web/templates/user/edit_web.html

+ 110 - 0
bin/v-add-web-domain-fast-cgi-cache

@@ -0,0 +1,110 @@
+#!/bin/bash
+# info: Adding fast cgi nginx support
+# options: USER DOMAIN [DEBUG]
+# labels: hestia web
+#
+# example: v-add-web-domain-fast-cgi-cache user domain.tld
+#
+# Function enables fast cgi support for Nginx
+# Add "yes" as last parameter append debug information to response headers
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+domain=$2
+debug=$3
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/hestia.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'USER DOMAIN DEBUG'
+is_format_valid 'user' 'domain'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'web' 'DOMAIN' "$domain"
+is_object_unsuspended 'web' 'DOMAIN' "$domain"
+
+# Perform verification if read-only mode is enabled
+check_hestia_demo_mode
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Load domain data
+parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
+
+# Check if web server is NGINX standalone
+if [ "$WEB_SYSTEM" != 'nginx' ]; then
+    echo "Error: NGINX not in Stand Alone mode"
+    exit $E_NOTEXIST
+fi
+
+
+if ! grep --quiet "forcessl" $HESTIA/data/templates/web/nginx/default.tpl; then
+    $BIN/v-update-web-templates
+fi
+fastcgi="$HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf"
+no_cache='$no_cache'
+cookie_session='$cookie_session'
+http_x_update='$http_x_update'
+status='$upstream_cache_status'
+
+cat << EOF > $fastcgi
+    fastcgi_cache $domain;
+    fastcgi_no_cache $no_cache;
+    fastcgi_cache_bypass $no_cache;
+    fastcgi_cache_bypass $cookie_session $http_x_update;
+EOF
+
+if [ ! -z "$debug" ]; then
+    echo "    add_header \"X-STATUS\" \"$status\";" >> $fastcgi
+fi
+
+chown root:$user $fastcgi
+chmod 640 $fastcgi
+
+str="fastcgi_cache_path /var/cache/nginx/php-fpm/$domain levels=2" 
+str="$str keys_zone=$domain:10m inactive=60m max_size=512m;" 
+conf='/etc/nginx/conf.d/01_fast_cgi_caching_pool.conf'
+if [ -e "$conf" ]; then
+    if [ -z "$(grep "=${domain}:" $conf)" ]; then
+        echo "$str" >> $conf
+    fi
+else
+    echo "$str" >> $conf
+fi
+
+mkdir -p /var/cache/nginx/php-fpm/$domain
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+if [ -z "$FASTCGI" ]; then
+    add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
+fi
+
+# Set FASTCGI flag to enabled
+update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' 'yes'
+
+# Restart web server
+$BIN/v-restart-web
+check_result $? "Web restart failed" > /dev/null
+
+# Logging
+log_history "enabled fast cgi support for $domain"
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 77 - 0
bin/v-add-web-domain-ssl-preset

@@ -0,0 +1,77 @@
+#!/bin/bash
+# info: remove fast cgi nginx support
+# options: USER DOMAIN [RESTART]
+# labels: hestia web
+#
+# example: v-delete-web-domain-fast-cgi-cache user domain.tld
+#
+# The function removes fast cgi cache.
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+domain=$2
+restart=$3
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/hestia.conf
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'USER DOMAIN'
+is_format_valid 'user' 'domain'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'web' 'DOMAIN' "$domain"
+is_object_unsuspended 'web' 'DOMAIN' "$domain"
+is_object_valid 'web' 'DOMAIN' "$domain" "$FASTCGI_CACHE"
+
+# Perform verification if read-only mode is enabled
+check_hestia_demo_mode
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Load domain data
+parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
+
+# Remove fast cgi configs
+if [ -f $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf ]; then
+    rm -f $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf
+fi
+
+# Delete cache folder on disabling
+if [ -d /var/cache/nginx/php-fpm/$domain ]; then
+    rm -f /var/cache/nginx/php-fpm/$domain
+fi
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+if [ -z "$FASTCGI_CACHE" ]; then
+    add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
+fi
+
+# Set FASTCGI flag to disabled
+update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' ''
+
+# Restart services if requested
+if [ ! -z "$restart" ]; then
+    $BIN/v-restart-web
+    check_result $? "Web restart failed" >/dev/null
+fi
+
+# Logging
+log_history "disabled fast cgi support for $domain"
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 1 - 0
bin/v-list-web-domain

@@ -44,6 +44,7 @@ json_list() {
         "BACKEND": "'$BACKEND'",
         "PROXY": "'$PROXY'",
         "PROXY_EXT": "'$PROXY_EXT'",
+        "FASTCGI_CACHE": "'$FASTCGI_CACHE'",
         "CUSTOM_DOCROOT": "'$CUSTOM_DOCROOT'",
         "SUSPENDED": "'$SUSPENDED'",
         "TIME": "'$TIME'",

+ 67 - 0
bin/v-purge-web-domain-nginx-cache

@@ -0,0 +1,67 @@
+#!/bin/bash
+# info: Empty nginx cache
+# options: USER DOMAIN MODE
+# labels: hestia web
+#
+# example: v-purge-web-domain-nginx-cache user domain.tld proxy
+#
+# The function clears Nginx cache.
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+domain=$2
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/hestia.conf
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'USER DOMAIN'
+is_format_valid 'user' 'domain'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'web' 'DOMAIN' "$domain"
+is_object_unsuspended 'web' 'DOMAIN' "$domain"
+is_object_valid 'web' 'DOMAIN' "$domain" "$FASTCGI_CACHE"
+
+# Perform verification if read-only mode is enabled
+check_hestia_demo_mode
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Load domain data
+parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
+
+# Empty Fast CGI Cache 
+if [ -d /var/cache/nginx/php-fpm/$domain ]; then
+    rm -fr /var/cache/nginx/php-fpm/$domain/*
+fi
+# Empty Proxy Cache
+if [ -d /var/cache/nginx/$domain ]; then
+    rm -fr /var/cache/nginx/$domain/*
+fi
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+# Restart services if requested
+if [ ! -z "$restart" ]; then
+    $BIN/v-restart-web
+    check_result $? "Web restart failed" >/dev/null
+fi
+
+# Logging
+log_history "purged nginx cache for $domain"
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 8 - 0
install/deb/nginx/nginx.conf

@@ -131,6 +131,14 @@ http {
     proxy_cache_use_stale error timeout invalid_header http_502;
     proxy_cache_valid any 1d;
 
+    # FastCGI Cache settings
+    fastcgi_cache_path /var/cache/nginx/php-fpm levels=2 keys_zone=fcgi_cache:10m inactive=60m max_size=1024m;
+    fastcgi_cache_key "$host$request_uri $cookie_user";
+    fastcgi_temp_path  /var/cache/nginx/temp;
+    fastcgi_ignore_headers Expires Cache-Control;
+    fastcgi_cache_use_stale error timeout invalid_header;
+    fastcgi_cache_valid any 1d;
+
     # Cache bypass
     map $http_cookie $no_cache {
         default 0;

+ 1 - 1
install/deb/templates/web/nginx/caching.stpl

@@ -17,7 +17,7 @@ server {
     location / {
         proxy_pass      https://%ip%:%web_ssl_port%;
 
-        proxy_cache cache;
+        proxy_cache %domain%;
         proxy_cache_valid 15m;
         proxy_cache_valid 404 1m;
         proxy_no_cache $no_cache;

+ 1 - 1
install/deb/templates/web/nginx/caching.tpl

@@ -12,7 +12,7 @@ server {
     location / {
         proxy_pass      http://%ip%:%web_port%;
 
-        proxy_cache cache;
+        proxy_cache %domain%;
         proxy_cache_valid 15m;
         proxy_cache_valid 404 1m;
         proxy_no_cache $no_cache;

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/cms_made_simple.stpl

@@ -35,6 +35,7 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         }
     }

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/cms_made_simple.tpl

@@ -30,6 +30,7 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         }
     }

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/codeigniter2.stpl

@@ -35,8 +35,9 @@ server {
 
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
-            fastcgi_param  SCRIPT_FILENAME /var/www/html/ci$fastcgi_script_name;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
+            fastcgi_param  SCRIPT_FILENAME /var/www/html/ci$fastcgi_script_name;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/codeigniter2.tpl

@@ -30,8 +30,9 @@ server {
 
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
-            fastcgi_param  SCRIPT_FILENAME /var/www/html/ci$fastcgi_script_name;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
+            fastcgi_param  SCRIPT_FILENAME /var/www/html/ci$fastcgi_script_name;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/codeigniter3.stpl

@@ -36,6 +36,7 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 0
install/deb/templates/web/nginx/php-fpm/codeigniter3.tpl

@@ -31,6 +31,8 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             include         /etc/nginx/fastcgi_params;
+            include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/datalife_engine.stpl

@@ -107,6 +107,7 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/datalife_engine.tpl

@@ -102,6 +102,7 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/default.stpl

@@ -35,6 +35,7 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/default.tpl

@@ -30,6 +30,7 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;     
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/dokuwiki.stpl

@@ -38,6 +38,7 @@ server {
             fastcgi_index   index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/dokuwiki.tpl

@@ -33,6 +33,7 @@ server {
             fastcgi_index   index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/drupal-composer.stpl

@@ -60,7 +60,8 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
-            include /etc/nginx/fastcgi_params;
+            include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/drupal-composer.tpl

@@ -56,7 +56,8 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
-            include /etc/nginx/fastcgi_params;
+            include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/drupal-social.stpl

@@ -60,7 +60,8 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
-            include /etc/nginx/fastcgi_params;
+            include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/drupal-social.tpl

@@ -56,7 +56,8 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
-            include /etc/nginx/fastcgi_params;
+            include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/drupal6.stpl

@@ -74,7 +74,8 @@ server {
         fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         fastcgi_pass %backend_lsnr%;             
-        include /etc/nginx/fastcgi_params;
+        include         /etc/nginx/fastcgi_params;
+        include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
     }
 
     location /error/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/drupal6.tpl

@@ -69,7 +69,8 @@ server {
         fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         fastcgi_pass %backend_lsnr%;             
-        include /etc/nginx/fastcgi_params;
+        include         /etc/nginx/fastcgi_params;
+        include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
     }
 
     location /error/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/drupal7.stpl

@@ -75,7 +75,8 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
-            include /etc/nginx/fastcgi_params;
+            include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/drupal7.tpl

@@ -70,7 +70,8 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
-            include /etc/nginx/fastcgi_params;
+            include         /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/drupal8.stpl

@@ -76,6 +76,7 @@ server {
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
             include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/drupal8.tpl

@@ -72,6 +72,7 @@ server {
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
             include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/joomla.stpl

@@ -42,7 +42,8 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/joomla.tpl

@@ -37,7 +37,8 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/laravel.stpl

@@ -34,7 +34,8 @@ server {
 
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/laravel.tpl

@@ -28,7 +28,8 @@ server {
 
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 6 - 3
install/deb/templates/web/nginx/php-fpm/magento.stpl

@@ -33,7 +33,8 @@ server {
             fastcgi_pass   %backend_lsnr%;
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
-            include        /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/setup/(?!pub/). {
@@ -55,7 +56,8 @@ server {
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             fastcgi_param  PATH_INFO        $fastcgi_path_info;
-            include        /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         # Deny everything but index.php
@@ -164,7 +166,8 @@ server {
 
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
-        include        /etc/nginx/fastcgi_params;
+        include /etc/nginx/fastcgi_params;
+        include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
     }
 
     gzip on;

+ 6 - 3
install/deb/templates/web/nginx/php-fpm/magento.tpl

@@ -28,7 +28,8 @@ server {
             fastcgi_pass   %backend_lsnr%;
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
-            include        /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/setup/(?!pub/). {
@@ -50,7 +51,8 @@ server {
             fastcgi_index  index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             fastcgi_param  PATH_INFO        $fastcgi_path_info;
-            include        /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         # Deny everything but index.php
@@ -159,7 +161,8 @@ server {
 
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
-        include        /etc/nginx/fastcgi_params;
+        include /etc/nginx/fastcgi_params;
+        include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
     }
 
     gzip on;

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/modx.stpl

@@ -51,6 +51,7 @@ server {
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME $request_filename;
         include /etc/nginx/fastcgi_params;
+        include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
     }
 
     location /error/ {

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/modx.tpl

@@ -45,6 +45,7 @@ server {
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME $request_filename;
         include /etc/nginx/fastcgi_params;
+        include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
     }
 
     location /error/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/moodle.stpl

@@ -69,7 +69,8 @@ server {
             fastcgi_param SCRIPT_FILENAME $request_filename;
 	    fastcgi_param PHP_VALUE open_basedir="/home/%user%/web/%domain%/private/moodledata:/home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/var/www/html:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/phppgadmin:/etc/roundcube:/var/lib/roundcube:/tmp:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt";
             fastcgi_intercept_errors on;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/moodle.tpl

@@ -65,7 +65,8 @@ server {
             fastcgi_param SCRIPT_FILENAME $request_filename;
 	    fastcgi_param PHP_VALUE open_basedir="/home/%user%/web/%domain%/private/moodledata:/home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/var/www/html:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/phppgadmin:/etc/roundcube:/var/lib/roundcube:/tmp:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt";
             fastcgi_intercept_errors on;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/opencart.stpl

@@ -34,7 +34,8 @@ server {
 
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/opencart.tpl

@@ -28,7 +28,8 @@ server {
 
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 0
install/deb/templates/web/nginx/php-fpm/owncloud.stpl

@@ -58,6 +58,8 @@ server {
             fastcgi_param PATH_INFO $fastcgi_path_info;
             #fastcgi_param HTTPS on;
             fastcgi_pass    %backend_lsnr%;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 0
install/deb/templates/web/nginx/php-fpm/owncloud.tpl

@@ -53,6 +53,8 @@ server {
             fastcgi_param PATH_INFO $fastcgi_path_info;
             #fastcgi_param HTTPS on;
             fastcgi_pass    %backend_lsnr%;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/piwik.stpl

@@ -42,7 +42,8 @@ server {
             }
 
             fastcgi_pass    %backend_lsnr%;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/piwik.tpl

@@ -37,7 +37,8 @@ server {
             }
 
             fastcgi_pass    %backend_lsnr%;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/prestashop.stpl

@@ -120,6 +120,7 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/prestashop.tpl

@@ -115,6 +115,7 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/pyrocms.stpl

@@ -40,7 +40,8 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/pyrocms.tpl

@@ -35,7 +35,8 @@ server {
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/sendy.stpl

@@ -53,6 +53,7 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location /l/ {

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/sendy.tpl

@@ -49,6 +49,7 @@ server {
             fastcgi_pass %backend_lsnr%;
             fastcgi_index index.php;
             include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location /l/ {

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/thunder.stpl

@@ -61,6 +61,7 @@ server {
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
             include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 1 - 0
install/deb/templates/web/nginx/php-fpm/thunder.tpl

@@ -57,6 +57,7 @@ server {
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $request_filename;
             include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
 
         location ~ ^/sites/.*/files/styles/ {

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/wordpress.stpl

@@ -51,7 +51,8 @@ server {
 
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 2 - 1
install/deb/templates/web/nginx/php-fpm/wordpress.tpl

@@ -46,7 +46,8 @@ server {
 
             fastcgi_pass    %backend_lsnr%;
             fastcgi_index   index.php;
-            include         /etc/nginx/fastcgi_params;
+            include /etc/nginx/fastcgi_params;
+            include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf;
         }
     }
 

+ 0 - 1
install/upgrade/versions/1.3.2.sh

@@ -5,4 +5,3 @@
 #######################################################################################
 #######                      Place additional commands below.                   #######
 #######################################################################################
-

+ 22 - 0
install/upgrade/versions/1.3.3.sh

@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Hestia Control Panel upgrade script for target version 1.3.3
+
+#######################################################################################
+#######                      Place additional commands below.                   #######
+#######################################################################################
+
+# Allow Fast CGI Cache to be enabled for Nginx Standalone
+if [ -e "/etc/nginx/nginx.conf" ]; then
+    echo "[*] Update Nginx to support fast cgi cache"
+    
+    check=$(cat /etc/nginx/nginx.conf | grep 'fastcgi_cache_path');
+    if [ -z "$check" ]; then 
+        echo '    [*] Install fast cgi cache support'
+        
+        sed  -i 's/# Cache bypass/# FastCGI Cache settings\n    fastcgi_cache_path \/var\/cache\/nginx\/php-fpm levels=2\n    keys_zone=fcgi_cache:10m inactive=60m max_size=1024m;\n    fastcgi_cache_key \"$host$request_uri $cookie_user\";\n    fastcgi_temp_path  \/var\/cache\/nginx\/temp;\n    fastcgi_ignore_headers Expires Cache-Control;\n    fastcgi_cache_use_stale error timeout invalid_header;\n    fastcgi_cache_valid any 1d;\n\n    # Cache bypass/g' /etc/nginx/nginx.conf
+        
+    else 
+        echo '    [!] fastcgi_cache_path found skipping install of fast cgi cache support!'
+    fi
+fi

+ 27 - 0
web/delete/web/cache/index.php

@@ -0,0 +1,27 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Check token
+if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
+    header('location: /login/');
+    exit();
+}
+
+// Delete as someone else?
+if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
+    $user=$_GET['user'];
+}
+
+if (!empty($_GET['domain'])) {
+    $v_username = escapeshellarg($user);
+    $v_domain = escapeshellarg($_GET['domain']);
+    exec (HESTIA_CMD."v-purge-web-domain-nginx-cache ".$v_username." ".$v_domain, $output, $return_var);
+    check_return_code($return_var,$output);
+}
+$_SESSION['ok_msg'] = _('Nginx cache has been sucessfully purged');
+header("Location: /edit/web/?domain=".$_GET['domain']);
+exit;

+ 14 - 0
web/edit/web/index.php

@@ -67,6 +67,7 @@ $v_letsencrypt = $data[$v_domain]['LETSENCRYPT'];
 if (empty($v_letsencrypt)) $v_letsencrypt = 'no';
 $v_ssl_home = $data[$v_domain]['SSL_HOME'];
 $v_backend_template = $data[$v_domain]['BACKEND'];
+$v_nginx_cache = $data[$v_domain]['FASTCGI_CACHE'];
 $v_proxy = $data[$v_domain]['PROXY'];
 $v_proxy_template = $data[$v_domain]['PROXY'];
 $v_proxy_ext = str_replace(',', ', ', $data[$v_domain]['PROXY_EXT']);
@@ -321,6 +322,19 @@ if (!empty($_POST['save'])) {
         unset($output);
     }
 
+    //Add / Delete caching support
+    if (($_SESSION['WEB_SYSTEM'] == 'nginx') && ($v_nginx_cache != $_POST['v_nginx_cache'] ) && (empty($_SESSION['error_msg']))) {
+        if ( $_POST['v_nginx_cache'] == 'yes' ) {
+           exec (HESTIA_CMD."v-add-web-domain-fast-cgi-cache ".$v_username." ".escapeshellarg($v_domain), $output, $return_var);
+           check_return_code($return_var,$output);
+           unset($output); 
+        } else {
+            exec (HESTIA_CMD."v-delete-web-domain-fast-cgi-cache ".$v_username." ".escapeshellarg($v_domain), $output, $return_var);
+            check_return_code($return_var,$output);
+            unset($output); 
+        }
+    }
+
     // Delete proxy support
     if ((!empty($_SESSION['PROXY_SYSTEM'])) && (!empty($v_proxy)) && (empty($_POST['v_proxy'])) && (empty($_SESSION['error_msg']))) {
         exec (HESTIA_CMD."v-delete-web-domain-proxy ".$v_username." ".escapeshellarg($v_domain)." 'no'", $output, $return_var);

+ 3 - 1
web/js/pages/add_web.js

@@ -225,7 +225,7 @@ $(function() {
 
     $('select[name="v_stats"]').change(function(evt){
         var select = $(evt.target);
-
+    
         if(select.val() == 'none'){
             $('.stats-auth').hide();
         } else {
@@ -234,6 +234,8 @@ $(function() {
     });
 });
 
+
+
 function WEBrandom() {
     var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
     var string_length = 16;

+ 20 - 0
web/js/pages/edit_web.js

@@ -235,6 +235,26 @@ $(function() {
             $('.stats-auth').show();
         }
     });
+    
+    $('select[name="v_nginx_cache"]').change(function(evt){
+        var select = $(evt.target);
+    
+        if(select.val() != 'yes'){
+            $('#v-clear-cache').hide();
+        } else {
+            $('#v-clear-cache').show();
+        }
+    });  
+    
+    $('select[name="v_proxy_template"]').change(function(evt){
+        var select = $(evt.target);
+
+        if(select.val() != 'caching'){
+            $('#v-clear-cache').hide();
+        } else {
+            $('#v-clear-cache').show();
+        }
+    });  
 
     $('#vstobjects').on('submit', function(evt) {
         $('input[disabled]').each(function(i, elm) {

+ 19 - 0
web/templates/admin/edit_web.html

@@ -4,6 +4,10 @@
             <a class="ui-button cancel" id="btn-back" href="/list/web/"><i class="fas fa-arrow-left status-icon blue"></i> <?=_('Back')?></a>
         </div>
         <div class="l-unit-toolbar__buttonstrip float-right">
+            <a href="/delete/web/cache/?domain=<?=$_GET['domain'];?>&token=<?=$_SESSION['token'];?>" class="ui-button cancel <?php if ( $v_nginx_cache == 'yes' || ($v_proxy_template == 'caching' && $_SESSION['PROXY'] == 'nginx')) { echo "block"; } else{ echo "hidden"; }?>" id="v-clear-cache">
+                <i class="fas fa-trash status-icon red"></i><?=_('Purge Nginx Cache');?>
+            </a>
+
             <a href="/add/webapp/?domain=<?=$v_domain?>" class="ui-button cancel">
                 <i class="fas fa-magic status-icon blue"></i> <?=_('Quick Install App')?>
             </a>
@@ -178,6 +182,21 @@
                                     </select>
                                 </td>
                             </tr>
+                            <?php if($_SESSION['WEB_SYSTEM'] == 'nginx'){?>
+                            <tr>
+                                <td class="vst-text input-label">
+                                    <?php print _('Enable Fast CGI Cache'); ?> <a href="https://docs.hestiacp.com/admin_docs/nginx_caching.html" target="_blank"><i class="fas fa-question-circle"></i></a>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <select class="vst-list" name="v_nginx_cache">
+                                        <option value="no"><?php echo _('No');?></option>
+                                        <option value="yes" <?php if ( $v_nginx_cache == "yes") { echo 'selected'; }?>><?php echo _('Yes');?></option>
+                                    </select>
+                                </td>
+                            </tr>
+                             <?php } ?>                          
                             <?php if (!empty($_SESSION['WEB_BACKEND'])) { ?>
                             <tr>
                                 <td class="vst-text input-label">

+ 19 - 13
web/templates/user/edit_web.html

@@ -4,6 +4,9 @@
             <a class="ui-button cancel" id="btn-back" href="/list/web/"><i class="fas fa-arrow-left status-icon blue"></i> <?=_('Back')?></a>
           </div>
           <div class="l-unit-toolbar__buttonstrip float-right">
+            <a href="/delete/web/cache/?domain=<?=$_GET['domain'];?>&token=<?=$_SESSION['token'];?>" class="ui-button cancel <?php if ( $v_nginx_cache == 'yes' || ($v_proxy_template == 'caching' && $_SESSION['PROXY'] == 'nginx')) { echo "block"; } else{ echo "hidden"; }?>" id="v-clear-cache">
+                <i class="fas fa-trash status-icon red"></i><?=_('Purge Nginx Cache');?>
+            </a>
             <a href="/add/webapp/?domain=<?=$v_domain?>" class="ui-button cancel">
                 <i class="fas fa-magic status-icon blue"></i> <?=_('Quick Install App')?>
             </a>
@@ -57,19 +60,6 @@
                                     ?>
                                 </td>
                             </tr>
-                            <tr>
-                                <td>
-                                    <?php
-                                        if (!empty($_SESSION['error_msg'])) {
-                                            echo "<span class=\"vst-error\"> <i class=\"fas fa-exclamation-circle status-icon red\"></i> ".htmlentities($_SESSION['error_msg'])."</span>";
-                                        } else {
-                                            if (!empty($_SESSION['ok_msg'])) {
-                                                echo "<span class=\"vst-ok\"> <i class=\"fas fa-check-circle status-icon green\"></i> ".$_SESSION['ok_msg']."</span>";
-                                            }
-                                        }
-                                    ?>
-                                </td>
-                            </tr>
                             <tr>
                                 <td class="vst-text step-top">
                                     <?php print _('Domain');?>
@@ -191,6 +181,21 @@
                                     </select>
                                 </td>
                             </tr>
+                            <?php if($_SESSION['WEB_SYSTEM'] == 'nginx'){?>
+                            <tr>
+                                <td class="vst-text input-label">
+                                    <?php print _('Enable Fast CGI Cache'); ?> <a href="https://docs.hestiacp.com/admin_docs/nginx_caching.html" target="_blank"><i class="fas fa-question-circle"></i></a>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <select class="vst-list" name="v_nginx_cache">
+                                        <option value="no"><?php echo _('No');?></option>
+                                        <option value="yes" <?php if ( $v_nginx_cache == "yes") { echo 'selected'; }?>><?php echo _('Yes');?></option>
+                                    </select>
+                                </td>
+                            </tr>
+                            <?php } ?>  
                             <?php if (!empty($_SESSION['WEB_BACKEND'])) { ?>
                             <tr>
                                 <td class="vst-text input-label">
@@ -217,6 +222,7 @@
                                 </td>
                             </tr>
                             <?php }?>
+                            
                             <?php if (!empty($_SESSION['PROXY_SYSTEM'])) { ?>
                             <tr>
                                 <td class="vst-text step-top">