Ignore SSL in Force-Redirect

New option to ignore SSL in force-redirect for some cases where WWW was not included in SSL.
This commit is contained in:
Cristhian Martínez Ochoa 2018-05-18 13:28:32 -06:00
parent f2fff2e377
commit 844b653e4e
2 changed files with 10 additions and 8 deletions

View file

@ -587,10 +587,12 @@ force_redirect() {
elif [[ -n $isssl && $value =~ ^(www|root)$ ]]; then
sudo sed -i '/listen 80/c \ listen 443 ssl http2;' /tmp/template-site-wwwredirect
sudo sed -i '/listen \[::\]:80/c \ listen [::]:443 ssl http2;' /tmp/template-site-wwwredirect
sudo sed -i '/headers-http.conf/a \ include common/headers-https.conf;' /tmp/template-site-wwwredirect
sudo sed -i '/server_name /r /opt/webinoly/templates/template-site-ssl' /tmp/template-site-wwwredirect
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s/domain.com/$domain/}" /tmp/template-site-wwwredirect
if [[ $cache != "-ignore-ssl" ]]; then
sudo sed -i '/headers-http.conf/a \ include common/headers-https.conf;' /tmp/template-site-wwwredirect
sudo sed -i '/server_name /r /opt/webinoly/templates/template-site-ssl' /tmp/template-site-wwwredirect
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s/domain.com/$domain/}" /tmp/template-site-wwwredirect
fi
sudo sed -i "/WebinolySSLredirectStart/,/WebinolySSLredirectEnd/s/\(server_name\).*$/$sername/" /etc/nginx/sites-available/$domain
sudo sed -i '/WebinolySSLredirectEnd/r /tmp/template-site-wwwredirect' /etc/nginx/sites-available/$domain

View file

@ -2,8 +2,8 @@
# Site Manager Plugin (Create, delete and de/activate)
# Syntax: site <domain> <option> <argument>
# Options: -html, -php, -mysql, -wp, -wpsubdir, -wpsubdom, -parked, -proxy, -on, -off, -delete, -delete-all, -list, -nocache, -cache, -ssl-on, ssl-off
# Arguments: -cache, -root, -subdomain
# Options: -html, -php, -mysql, -wp, -wpsubdir, -wpsubdom, -parked, -proxy, -on, -off, -delete, -delete-all, -list, -nocache, -cache, -ssl-on, ssl-off, -force-redirect
# Arguments: -cache, -root, -subdomain, -ignore-ssl
# shopt is necessary for this kind !(html|22222) of patterns
shopt -s extglob
@ -24,7 +24,7 @@ if [[ ! $(conf_read nginx) == "true" ]]; then
fi
# Check if user entered arg before option and correct it.
if [[ "$type" == "-cache" && -n $cache ]]; then
if [[ -n $cache && ($type == "-cache" || $type == "-ignore-ssl") ]]; then
type="$3"
cache="$2"
fi
@ -108,10 +108,10 @@ if [[ $type == "-wp" || $type == "-wpsubdir" || $type == "-wpsubdom" || $type ==
fi
# Cache validation
if [[ $cache == "-cache" && $wp == "0" ]]; then
if [[ $cache == "-cache" && $wp == [045] ]]; then
echo "${red} Site $domain is not a WP site! ${end}"
exit 1
elif [[ -n $cache && ( $cache != "-cache" && $cache != "-root" && $cache != "-subdomain" ) && $type != "-parked" ]]; then
elif [[ -n $cache && ( $cache != "-cache" && $cache != "-root" && $cache != "-subdomain" && $cache != "-ignore-ssl" ) && $type != "-parked" ]]; then
echo "${red} $cache is not a valid argument! ${end}"
exit 1
fi