From b2653d82830b90512206d5ef7e2973af18e2400d Mon Sep 17 00:00:00 2001 From: neodarz Date: Wed, 2 Aug 2017 01:13:11 +0200 Subject: initial commit --- create_apache_conf.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 create_apache_conf.sh (limited to 'create_apache_conf.sh') diff --git a/create_apache_conf.sh b/create_apache_conf.sh new file mode 100755 index 0000000..28c7769 --- /dev/null +++ b/create_apache_conf.sh @@ -0,0 +1,96 @@ + +usage () { + echo "You must set a $1 !" + echo "Usage:" + echo " create_apache_conf.sh " + exit 0 +} + +if [ -z $1 ]; then + usage "USER" +fi + + +USER=$1 + +cat > /etc/apache2/sites-available/$USER.kresus.neodarz.net.conf << EOF + + ServerName $USER.kresus.neodarz.net + ServerAdmin me@example.net + + #Alias /.well-known/acme-challenge /tmp/.well-known/acme-challenge + + + Options None + AllowOverride None + + Require all granted + AddDefaultCharset off + + AuthType None + Satisfy any + + + Redirect permanent / https://$USER.kresus.neodarz.net/ + + ErrorLog /home/website/kresus-gen/logs/error.log + CustomLog /home/website/kresus-gen/logs/access.log combined + +EOF + +cat > /etc/apache2/sites-available/$USER.kresus.neodarz.net-le-ssl.conf << EOF + + + ServerName $USER.kresus.neodarz.net + ServerAdmin me@example.net + + ProxyPass "/" "http://127.0.0.1:9876/" + ProxyPassReverse "/" "http://127.0.0.1:9876/" + + Alias /.well-known/acme-challenge /tmp/.well-known/acme-challenge + + + Options None + AllowOverride None + + Require all granted + AddDefaultCharset off + + AuthType None + Satisfy any + + + + AuthUserFile /home/website/kresus-gen/$USER.kresus.neodarz.net/.htpasswd + AuthName "Authentification" + AuthType Basic + Require valid-user + + + SSLEngine on + + SSLCertificateKeyFile /etc/letsencrypt/live/$USER.kresus.neodarz.net/privkey.pem + SSLCertificateFile /etc/letsencrypt/live/$USER.kresus.neodarz.net/fullchain.pem + + Header always set Strict-Transport-Security "max-age=15768000" + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + ErrorLog /home/website/kresus-gen/logs/error.log + CustomLog /home/website/kresus-gen/logs/access.log combined + + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +EOF + +certbot --apache -d $USER.kresus.neodarz.net + +a2ensite $USER.kresus.neodarz.net +systemctl reload apache2 + -- cgit v1.2.1