7.4.16

zPanel mit SSL - Part 2

Nach der Installation mehrerer Zertifikate von letsencrypt hatte ich zunächst mit "Override a Virtual Host Setting" diese eingefügt.
Das klappte aber nur bedingt. Trotz nahezu identischer Einstellungen konnte man  manchmal per https zugreifen und gleichzeitig per http, aber manchmal komischerweise nicht.
Außerdem wurde bei manchen Domains das CSS nicht mehr richtig angezeigt.

Hier nun eine (wie immer geklaute) Anleitung, mit der es klappen soll.

Meine Zertifikate für jede Domain liegen in

/etc/letsencrypt/live/[DOMAIN]

Dort relevant fullchain.pem und privkey.pem.


Damit das Ganze mehr oder weniger automatisiert abläuft, habe ich mir eine SSL-Vorlage erstellt:


# DOMAIN: NEWDOMAIN
<virtualhost *:443>
ServerName NEWDOMAIN
ServerAlias NEWDOMAIN www.NEWDOMAIN
ServerAdmin admin@localhost.de
DocumentRoot "/var/zpanel/hostdata/zadmin/public_html/NEWPATH"
php_admin_value open_basedir "/var/zpanel/hostdata/zadmin/public_html/NEWPATH:/var/zpanel/temp/"
php_admin_value suhosin.executor.func.blacklist "passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec"
ErrorLog "/var/zpanel/logs/domains/zadmin/NEWDOMAIN-error.log"
CustomLog "/var/zpanel/logs/domains/zadmin/NEWDOMAIN-access.log" combined
CustomLog "/var/zpanel/logs/domains/zadmin/NEWDOMAIN-bandwidth.log" common
<Directory />
Options FollowSymLinks Indexes
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
AddType application/x-httpd-php .php3 .php
ScriptAlias /cgi-bin/ "/_cgi-bin/"
<location /cgi-bin>
AddHandler cgi-script .cgi .pl
Options ExecCGI -Indexes
</location>
DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtm
# Custom Global Settings (if any exist)
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/NEWDOMAIN/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/NEWDOMAIN/privkey.pem

# Custom VH settings (if any exist)

</virtualhost>
# END DOMAIN: NEWDOMAIN



Dann habe ich  ein Verzeichnis
/etc/zpanel/configs/apache/ssl_enabled 
erstellt, in dem dann die SSL-Konfigurationen hineinkopiert werden sollen.

Damit diese includiert werden einfach in die

/etc/zpanel/configs/apache/http.conf 

folgende Zeile einfügen:

 # Custom SSL Apache config
Include /etc/zpanel/configs/apache/ssl_enabled

Das nachfolgende Script (create-ssl-domain.sh) erwartet als ersten Parameter die Domain, für die ein SSL-Eintrag eingerichtet werden soll:

#!/bin/bash

CONFIGPATH=/etc/zpanel/configs/apache/ssl_enabled
VORLAGE=/etc/zpanel/configs/apache/VORLAGE
domainstring="s/NEWDOMAIN/$1/g"
replacepath=`echo $1 | sed 's/\./_/g'`
pathstring="s/NEWPATH/$replacepath/g"

if [ ! "$1" ]; then
echo "Fehler! Domain übergeben!"
    exit 0
fi

echo "Bereite SSL für Domain " $1 "vor"
sed -e $domainstring -e $pathstring $VORLAGE > $CONFIGPATH/$1.conf

Ausführbar machen, dann ausführen mit

create-ssl-domain.sh [DOMAIN]

und schwups, eine neue Konfiguration ist angelegt und wenn die entsprechenden Zertifikate vorhanden sind, meckert der Apache bei einem

service apache2 restart

auch nicht!



Keine Kommentare:

Kommentar veröffentlichen

Openhab und Ecoflow Max - API Anbindung

 Ich wollte die neu erworbene Powerstation in Openhab einbinden, um den aktuellen Status (Ladestand etc.) über Openhab auswerten zu können. ...