Apache How to's: Unterschied zwischen den Versionen
Froggi (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „=== Self signed certificate === '''Oder auch selbst unterzeichnetes Zertifikat''' Wozu? Um https (''TLS / SSL'') simulieren / nutzen zu können auf dem Heims…“) |
Froggi (Diskussion | Beiträge) |
||
| Zeile 65: | Zeile 65: | ||
</VirtualHost> | </VirtualHost> | ||
</IfModule> | </IfModule> | ||
| + | |||
| + | Die "normale" Konfiguration erweiter wir noch um: | ||
| + | |||
| + | Redirect "/" <nowiki>"https://www.webseite.local/"</nowiki> | ||
| + | |||
| + | so das das dann so in etwa ausschaut: | ||
| + | |||
| + | <VirtualHost *:80> | ||
| + | ServerName www.webseite.local | ||
| + | DocumentRoot /var/www/webseite/public | ||
| + | |||
| + | <Directory /var/www/webseite/public> | ||
| + | AllowOverride All | ||
| + | Require all granted | ||
| + | </Directory> | ||
| + | ErrorLog ${APACHE_LOG_DIR}/webseite_error.log | ||
| + | CustomLog ${APACHE_LOG_DIR}/webseite_access.log combined | ||
| + | |||
| + | Redirect "/" <nowiki>"https://www.webseite.local/"</nowiki> | ||
| + | </VirtualHost> | ||
| + | |||
| + | Mit | ||
| + | a2enmod ssl | ||
| + | und | ||
| + | a2ensite webseite-ssl.conf | ||
| + | sowohl SSL als auch die Webseitenkonfiguration aktivieren. | ||
| + | |||
| + | Apache neuladen mit | ||
| + | systemctl restart apache (''systemd'') | ||
Version vom 19. März 2020, 13:31 Uhr
Self signed certificate
Oder auch selbst unterzeichnetes Zertifikat
Wozu? Um https (TLS / SSL) simulieren / nutzen zu können auf dem Heimserver oder virtuellem Server ohne echte Domain.
Mit OpenSSL installiert folgenden Befehl ausführen:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/webseite-selfsigned.key -out /etc/ssl/certs/webseite-selfsigned.crt
Wobei derzeit (Stand März 2020) die Schlüssellänge von 2048 (-newkey rsa:2048) ausreicht. Erste Schritte Richtung einer Länge von 4096 werden genannt, aber nicht vorgeschrieben.
You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:DE State or Province Name (full name) [Some-State]:Land Locality Name (eg, city) []:Wohnort Organization Name (eg, company) [Internet Widgits Pty Ltd]:Abteilungsname Organizational Unit Name (eg, section) []:Development Common Name (e.g. server FQDN or YOUR name) []:www.webseite.local Email Address []:admin@webseite.local
Nun müssen wir Apache noch beibringen https und das Zertifikat zu nutzen.
Dazu am besten die bestehende webseite.conf in /etc/apache/sites-available nach webseite-ssl.conf kopieren. Diese dann editieren und so was wie im folgenden Beispiel daraus machen:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin admin@webseite.local
ServerName www.webseite.local
DocumentRoot /var/www/webseite/public
<Directory /var/www/webseite/public>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/webseite_error.log
CustomLog ${APACHE_LOG_DIR}/webseite_access.log combined
SSLEngine on
##
# Dies sind die zwei Dateien, die wir vorhin weiter oben erstellt haben.
##
SSLCertificateFile /etc/ssl/certs/webseite-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/webseite-selfsigned.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
Die "normale" Konfiguration erweiter wir noch um:
Redirect "/" "https://www.webseite.local/"
so das das dann so in etwa ausschaut:
<VirtualHost *:80>
ServerName www.webseite.local
DocumentRoot /var/www/webseite/public
<Directory /var/www/webseite/public>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/webseite_error.log
CustomLog ${APACHE_LOG_DIR}/webseite_access.log combined
Redirect "/" "https://www.webseite.local/"
</VirtualHost>
Mit
a2enmod ssl
und
a2ensite webseite-ssl.conf
sowohl SSL als auch die Webseitenkonfiguration aktivieren.
Apache neuladen mit
systemctl restart apache (systemd)