SSL for subdomain

Remove www from LE request when subdomain
This commit is contained in:
Cristhian Martínez Ochoa 2018-02-14 20:32:43 -07:00
parent bf16306d28
commit cb11a00607
2 changed files with 13 additions and 4 deletions

View file

@ -38,18 +38,19 @@ site_ssl_on() {
echo "${end}"
done
# Generar nuevo certificado
if [[ ! -a /etc/letsencrypt/live/$domain/fullchain.pem ]]; then
# Create new certificate
if [[ ! -a /etc/letsencrypt/live/$domain/fullchain.pem && $subdomflag == 0 ]]; then
sudo letsencrypt certonly --webroot -w /var/www/$root/htdocs/ -d $domain -d www.$domain --email $cermail --agree-tos
elif [[ ! -a /etc/letsencrypt/live/$domain/fullchain.pem && $subdomflag == 1 ]]; then
sudo letsencrypt certonly --webroot -w /var/www/$root/htdocs/ -d $domain --email $cermail --agree-tos
fi
# Configuracion NGINX del sitio para soportar SSL
# SSL Nginx Conf
if [[ -a /etc/letsencrypt/live/$root/fullchain.pem ]]; then
sudo sed -i '/listen 80/c \ listen 443 ssl http2;' /etc/nginx/sites-available/$domain
sudo sed -i '/listen \[::\]:80/c \ listen [::]:443 ssl http2;' /etc/nginx/sites-available/$domain
sudo sed -i '/headers-html.conf/a \ include common/headers-https.conf;' /etc/nginx/sites-available/$domain
sudo sed -i '/server_name /r /opt/webinoly/templates/template-site-ssl' /etc/nginx/sites-available/$domain
#sudo sed -i "s/domain.com/${root}/g" /etc/nginx/sites-available/$domain
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s/domain.com/$domain/}" /etc/nginx/sites-available/$domain
# Auto-Renew Certificate

View file

@ -30,6 +30,14 @@ if [[ "$type" == "-cache" && -n $cache ]]; then
cache="$2"
fi
# Check if site is sub-domain
subdom=$(echo "${domain}" | cut -d'.' -f 3 -s)
if [[ -z $subdom ]]; then
subdomflag="0"
else
subdomflag="1"
fi
wp="0" # Evaluate if site to create is WP ( 0 = noWP, 1 = WP, 2 = WP with default values, 3 = WP with custom values )
if [[ "$type" == "-wp" || "$type" == "-wpsubdir" || "$type" == "-wpsubdom" ]]; then
wp="1"