Skip to content

Commit

Permalink
sites
Browse files Browse the repository at this point in the history
Fixed - Parked sites nginx error when main site has the force redirect option enabled.
Fixed - Create WP site with subfolder failing when cache parameter is passed in the same line and main site exists.
Fixed - Reset custom cache not working in proxy sites.
Improved - Reset custom cache now works even when cache is already disabled.
  • Loading branch information
QROkes committed Jun 22, 2023
1 parent d0891dc commit 2baf0a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/sites
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,9 @@ parked_domain() {
sudo truncate -s 0 /etc/nginx/sites-available/$domain
sudo cat /etc/nginx/sites-available/$parked > /etc/nginx/sites-available/$domain

# Just in case: Remove Force-Redirect if enabled!
sudo sed -i '/WebinolyWWWredirectStart/,/WebinolyWWWredirectEnd/{/.*/d}' /etc/nginx/sites-available/$domain

# Prevent if SSL is enabled in main site and ssl data is copied to parked site causing an error.
[[ $(is_ssl $parked) == "true" ]] && sudo site $domain -ssl=off -revoke=off -no-db-update > /dev/null 2>&1

Expand Down Expand Up @@ -1475,6 +1478,8 @@ wp_cache() {
elif [[ $(is_cache $domain $subfolder) == "proxy" ]]; then
sudo sed -i "/proxy_cache .*;/c \ proxy_cache off;" /etc/nginx/apps.d/$domain$subname-proxy.conf
echo "${gre}Proxy Cache in${blu} $domain$subfolder ${gre}has been disabled!${end}"
[[ -n $reset && -n $subfolder ]] && site $domain -cache=custom -reset -subfolder=$subfolder
[[ -n $reset && -z $subfolder ]] && site $domain -cache=custom -reset
elif [[ -n $subfolder && $(is_cache $domain $subfolder) == "wp" ]]; then
sudo sed -i "/apps.d\/$domain$subname-wpfc.conf;/c \ include apps.d/$domain$subname-php.conf;" /etc/nginx/sites-available/$domain
echo "${gre}FastCGI Cache in${blu} $domain$subfolder ${gre}has been disabled!${end}"
Expand All @@ -1483,6 +1488,10 @@ wp_cache() {
echo "${gre}FastCGI Cache in${blu} $domain ${gre}has been disabled!${end}"
else
echo "${gre}Nginx Cache is already disabled on your site${blu} $domain${end}"

# Needed to support the reset option even when already off
[[ -n $reset && -n $subfolder ]] && site $domain -cache=custom -reset -subfolder=$subfolder
[[ -n $reset && -z $subfolder ]] && site $domain -cache=custom -reset
fi
elif [[ $cache == "on" ]]; then
api-events_update si8
Expand Down Expand Up @@ -1539,6 +1548,7 @@ wp_cache() {
elif [[ $(is_proxy $domain $subfolder) == "true" && -n $(grep -F "# WebinolyProxyCacheStart" /etc/nginx/apps.d/$domain$subname-proxy.conf) ]]; then
sudo sed -i '/WebinolyProxyCacheStart/,/WebinolyProxyCacheEnd/{/.*/d}' /etc/nginx/apps.d/$domain$subname-proxy.conf
sudo sed -i "/^proxy_cache_path \/run\/nginx-cache\/$(echo $domain | sed 's/[^0-9A-Za-z]/_/g')${subname} .*/d" /etc/nginx/conf.d/webinoly.conf
[[ -f /etc/nginx/apps.d/${domain}${subname}-site_custom_cache.conf ]] && sudo rm /etc/nginx/apps.d/${domain}${subname}-site_custom_cache.conf
echo "${gre}Custom Proxy Cache configuration has been successfully removed! ${end}"
elif [[ -f /etc/nginx/apps.d/$domain$subname-${fn}.conf ]]; then
sudo rm /etc/nginx/apps.d/$domain$subname-${fn}.conf
Expand Down
2 changes: 1 addition & 1 deletion usr/site
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ elif [[ -n $subfolder && -z $delete && -z $cache && -z $multisite_convert && -z
echo "${red}[ERROR] Subfolder option not supported!${end}"
exit 1
# Clone-from empty is here to allow -cache=on when cloning a site
elif [[ -n $subfolder && ( $cache == "on" || -n $multisite_convert || -n $replace_content ) && $(is_subfolder $domain $subfolder) != "wp" && -z $clone_from ]]; then
elif [[ -n $subfolder && -z $wp && ( $cache == "on" || -n $multisite_convert || -n $replace_content ) && $(is_subfolder $domain $subfolder) != "wp" && -z $clone_from ]]; then
echo "${red}[ERROR] Subfolder not found or is not a WP site!${end}"
exit 1
else
Expand Down

0 comments on commit 2baf0a9

Please sign in to comment.