Skip to content

Commit f7a5035

Browse files
author
Alexandros Ioannides
authored
Update and rename v-add-web-domain-fast-cgi-cache to v-add-fastcgi-cache
1 parent 7d4f91d commit f7a5035

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/bash
2-
# info: Adding fast cgi nginx support
2+
# info: Adding FastCGI nginx support
33
# options: USER DOMAIN [DEBUG]
44
# labels: hestia web
55
#
6-
# example: v-add-web-domain-fast-cgi-cache user domain.tld
6+
# example: v-add-fastcgi-cache user domain.tld
77
#
8-
# Function enables fast cgi support for Nginx
9-
# Add "yes" as last parameter append debug information to response headers
8+
# Function enables FastCGI cache for nginx
9+
# Add "yes" as last parameter to append debug information to response headers
1010

1111

1212
#----------------------------------------------------------#
@@ -45,16 +45,16 @@ check_hestia_demo_mode
4545
# Load domain data
4646
parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
4747

48-
# Check if web server is NGINX standalone
48+
# Check if nginx is not in proxy mode
4949
if [ "$WEB_SYSTEM" != 'nginx' ]; then
50-
echo "Error: NGINX not in Stand Alone mode"
50+
echo "Error: nginx is in proxy mode"
5151
exit $E_NOTEXIST
5252
fi
5353

54-
5554
if ! grep --quiet "forcessl" $HESTIA/data/templates/web/nginx/default.tpl; then
5655
$BIN/v-update-web-templates
5756
fi
57+
5858
fastcgi="$HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf"
5959
no_cache='$no_cache'
6060
cookie_session='$cookie_session'
@@ -63,9 +63,11 @@ status='$upstream_cache_status'
6363

6464
cat << EOF > $fastcgi
6565
fastcgi_cache $domain;
66-
fastcgi_no_cache $no_cache;
66+
fastcgi_cache_valid 200 2m;
67+
fastcgi_cache_valid 301 302 10m;
68+
fastcgi_cache_valid 404 10m;
6769
fastcgi_cache_bypass $no_cache;
68-
fastcgi_cache_bypass $cookie_session $http_x_update;
70+
fastcgi_no_cache $no_cache;
6971
EOF
7072

7173
if [ ! -z "$debug" ]; then
@@ -75,9 +77,9 @@ fi
7577
chown root:$user $fastcgi
7678
chmod 640 $fastcgi
7779

78-
str="fastcgi_cache_path /var/cache/nginx/php-fpm/$domain levels=2"
79-
str="$str keys_zone=$domain:10m inactive=60m max_size=512m;"
80-
conf='/etc/nginx/conf.d/01_fast_cgi_caching_pool.conf'
80+
str="fastcgi_cache_path /var/cache/nginx/micro/$domain levels=1:2"
81+
str="$str keys_zone=$domain:10m max_size=512m inactive=30m;"
82+
conf='/etc/nginx/conf.d/fastcgi_cache_pool.conf'
8183
if [ -e "$conf" ]; then
8284
if [ -z "$(grep "=${domain}:" $conf)" ]; then
8385
echo "$str" >> $conf
@@ -86,7 +88,7 @@ else
8688
echo "$str" >> $conf
8789
fi
8890

89-
mkdir -p /var/cache/nginx/php-fpm/$domain
91+
mkdir -p /var/cache/nginx/micro/$domain
9092

9193
#----------------------------------------------------------#
9294
# Hestia #
@@ -96,15 +98,15 @@ if [ -z "$FASTCGI" ]; then
9698
add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
9799
fi
98100

99-
# Set FASTCGI flag to enabled
101+
# Set FastCGI cache flag to enabled
100102
update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' 'yes'
101103

102104
# Restart web server
103105
$BIN/v-restart-web
104106
check_result $? "Web restart failed" > /dev/null
105107

106108
# Logging
107-
log_history "enabled fast cgi support for $domain"
109+
log_history "Enabled FastCGI cache for $domain"
108110
log_event "$OK" "$ARGUMENTS"
109111

110112
exit

0 commit comments

Comments
 (0)