set trusted domain and redirect to ssl

This commit is contained in:
Daniel Hansson 2016-12-30 21:50:17 +01:00
parent bcbf5fa53e
commit 231b39dca0
2 changed files with 26 additions and 19 deletions

View File

@ -183,6 +183,11 @@ else
echo "$ssl_conf was successfully created"
sleep 3
cat << SSL_CREATE > "$ssl_conf"
<VirtualHost *:80>
ServerName $domain
Redirect / https://$domain
</VirtualHost>
<VirtualHost *:443>
Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"

View File

@ -11,6 +11,7 @@ read -p "Press any key to continue... " -n1 -s
echo -e "\e[0m"
a2ensite $1
a2dissite nextcloud_ssl_domain_self_signed.conf
a2dissite nextcloud_http_domain_self_signed.conf
service apache2 restart
if [[ "$?" == "0" ]]
then
@ -48,6 +49,25 @@ CRONTAB
# Makeletsencryptrenew.sh executable
chmod +x $SCRIPTS/letsencryptrenew.sh
# Cleanup
rm $SCRIPTS/test-new-config.sh
rm $SCRIPTS/activate-ssl.sh
else
# If it fails, revert changes back to normal
a2dissite $1
a2ensite nextcloud_ssl_domain_self_signed.conf
a2ensite nextcloud_http_domain_self_signed.conf
service apache2 restart
echo -e "\e[96m"
echo "Couldn't load new config, reverted to old settings. Self-signed SSL is OK!"
echo -e "\e[0m"
echo -e "\e[32m"
read -p "Press any key to continue... " -n1 -s
echo -e "\e[0m"
exit 1
fi
# Update Config
if [ -f $SCRIPTS/update-config.php ]
then
@ -57,7 +77,7 @@ else
wget -q $STATIC/update-config.php -P $SCRIPTS
fi
# Sets trusted domain in when nextcloud-startup-script.sh is finished
# Sets trusted domain in config.php
if [ -f $SCRIPTS/trusted.sh ]
then
rm $SCRIPTS/trusted.sh
@ -70,22 +90,4 @@ bash $SCRIPTS/trusted.sh
rm $SCRIPTS/trusted.sh
rm $SCRIPTS/update-config.php
# Cleanup
rm $SCRIPTS/test-new-config.sh
rm $SCRIPTS/activate-ssl.sh
else
# If it fails, revert changes back to normal
a2dissite $1
a2ensite nextcloud_ssl_domain_self_signed.conf
service apache2 restart
echo -e "\e[96m"
echo "Couldn't load new config, reverted to old settings. Self-signed SSL is OK!"
echo -e "\e[0m"
echo -e "\e[32m"
read -p "Press any key to continue... " -n1 -s
echo -e "\e[0m"
exit 1
fi
exit 0