Readme.md hinzugefügt
This commit is contained in:
111
Readme.md
Normal file
111
Readme.md
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
## Lokalen Apache-Webserver mit Self-Signed Certificate absichern
|
||||||
|
|
||||||
|
### 1. OpenSSL zur Zertifikatserstellung verwenden
|
||||||
|
Falls OpenSSL nicht installiert ist:
|
||||||
|
- **Debian/Ubuntu:** `sudo apt install openssl`
|
||||||
|
- **CentOS/RHEL:** `sudo yum install openssl`
|
||||||
|
- **Windows:** [OpenSSL Binaries herunterladen](https://slproweb.com/products/Win32OpenSSL.html)
|
||||||
|
|
||||||
|
Verzeichnis für Zertifikate erstellen:
|
||||||
|
```bash
|
||||||
|
sudo mkdir -p /etc/apache2/ssl
|
||||||
|
cd /etc/apache2/ssl
|
||||||
|
```
|
||||||
|
|
||||||
|
Privaten Schlüssel und Zertifikat generieren:
|
||||||
|
```bash
|
||||||
|
sudo openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout apache-selfsigned.key -out apache-selfsigned.crt
|
||||||
|
```
|
||||||
|
Angabe des Common Name (CN) mit **IP-Adresse** oder **Domainnamen** (z. B. `localhost`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 2. Apache für SSL konfigurieren
|
||||||
|
SSL-Modul aktivieren:
|
||||||
|
```bash
|
||||||
|
sudo a2enmod ssl
|
||||||
|
sudo systemctl restart apache2
|
||||||
|
```
|
||||||
|
|
||||||
|
SSL-VHost-Konfiguration bearbeiten:
|
||||||
|
```bash
|
||||||
|
sudo nano /etc/apache2/sites-available/default-ssl.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Konfiguration anpassen:
|
||||||
|
```apache
|
||||||
|
<VirtualHost *:443>
|
||||||
|
ServerAdmin webmaster@localhost
|
||||||
|
DocumentRoot /var/www/html
|
||||||
|
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile /etc/apache2/ssl/apache-selfsigned.crt
|
||||||
|
SSLCertificateKeyFile /etc/apache2/ssl/apache-selfsigned.key
|
||||||
|
|
||||||
|
<Directory /var/www/html>
|
||||||
|
Options Indexes FollowSymLinks
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
```
|
||||||
|
|
||||||
|
SSL-Host aktivieren und Apache neu starten:
|
||||||
|
```bash
|
||||||
|
sudo a2ensite default-ssl
|
||||||
|
sudo systemctl restart apache2
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3. Firewall-Regeln anpassen (optional)
|
||||||
|
Falls UFW aktiv ist:
|
||||||
|
```bash
|
||||||
|
sudo ufw allow 'Apache Full'
|
||||||
|
```
|
||||||
|
Falls `firewalld` genutzt wird:
|
||||||
|
```bash
|
||||||
|
sudo firewall-cmd --permanent --add-service=https
|
||||||
|
sudo firewall-cmd --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 4. Zertifikat im Browser vertrauen
|
||||||
|
Da es ein selbstsigniertes Zertifikat ist, muss es manuell als vertrauenswürdig markiert werden:
|
||||||
|
- **Windows:** `certmgr.msc` öffnen → "Vertrauenswürdige Stammzertifizierungsstellen" → Zertifikat importieren.
|
||||||
|
- **Linux:**
|
||||||
|
```bash
|
||||||
|
sudo cp apache-selfsigned.crt /usr/local/share/ca-certificates/
|
||||||
|
sudo update-ca-certificates
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5. Automatische HTTPS-Weiterleitung (optional)
|
||||||
|
HTTP zu HTTPS weiterleiten:
|
||||||
|
```bash
|
||||||
|
sudo nano /etc/apache2/sites-available/000-default.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Folgenden Inhalt hinzufügen:
|
||||||
|
```apache
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin webmaster@localhost
|
||||||
|
DocumentRoot /var/www/html
|
||||||
|
Redirect permanent / https://localhost/
|
||||||
|
</VirtualHost>
|
||||||
|
```
|
||||||
|
|
||||||
|
Apache neu starten:
|
||||||
|
```bash
|
||||||
|
sudo systemctl restart apache2
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Jetzt ist der Apache-Server mit HTTPS (self-signed) erreichbar. 🎉
|
||||||
|
|
Reference in New Issue
Block a user