VErsion 3.3.0p3
This commit is contained in:
202
INSTALLATION.md
Normal file
202
INSTALLATION.md
Normal file
@@ -0,0 +1,202 @@
|
||||
Da ich keine neuen, teuren IPv4-Adressen kaufen wollte oder möglicherweise einmal keine mehr bekommen würde, habe ich Folgendes konfiguriert, um reine IPv6-LXC-Container oder VMs mit IPv4 versorgen zu können. Es ist zwar meine Idee, aber nicht ganz allein meine Arbeit. ChatGPT hat mir dabei geholfen. Die Zusammenfassung hat mir auch ChatGPT erstellt. Es funktioniert, die Zugriffe sind drastisch schneller geworden, weil nun ein Nginx Proxy davor ist, der die Architektur in mehreren Punkten optimiert. Allerdings sind jedoch im DNS einige VMs/LXC Container unter einer IPv4 und einer IPv6 zusammengefasst. Ob man einen Mailserver auch einbindet, sollte man sich gut überlegen. Spamt ein Container, ist auch der Mailserver auf der Blacklist, weil er dieselbe IP hat.
|
||||
Ich hoffe, es sind alle Schritte zusammengefasst.
|
||||
Dies ist der aktuelle Status:
|
||||
|
||||
|
||||
# Technische Systembeschreibung – Edge-Proxy und WireGuard unter Debian 12 mit ISPConfig
|
||||
|
||||
## 1. Systemübersicht
|
||||
|
||||
Dieses Setup beschreibt eine Debian-12-Installation mit ISPConfig, die als kombinierter Reverse-Proxy (TLS-Passthrough) und WireGuard-Server für IPv4-Egress dient.
|
||||
„Edge-Proxy“ = öffentlicher Dual-Stack-Server, „Client 1“ = internes IPv6-only-System mit IPv4-Tunnel.
|
||||
|
||||
## 2. Paketinstallation
|
||||
|
||||
```bash
|
||||
apt update
|
||||
apt install nginx-full libnginx-mod-stream wireguard iptables
|
||||
```
|
||||
|
||||
Falls Apache durch ISPConfig aktiv ist, sicherstellen, dass dieser nicht auf den Ports 80/443 lauscht, um Portkonflikte zu vermeiden.
|
||||
|
||||
## 3. Netzwerkkonzept
|
||||
|
||||
Der Edge-Proxy ist Dual-Stack-fähig mit öffentlicher IPv4- und IPv6-Adresse. Backends (inklusive Client 1) nutzen native IPv6; IPv4-Datenverkehr wird über WireGuard getunnelt. DNS-A/AAAA-Einträge verweisen auf den Edge-Proxy; SSH erfolgt direkt über IPv6.
|
||||
|
||||
## 4. Nginx-Reverse-Proxy-Konfiguration
|
||||
|
||||
### 4.1 Host-Mapping
|
||||
|
||||
**Datei:** `/etc/nginx/maps/host_upstreams.inc` (Webseitenzuordnung)
|
||||
|
||||
```text
|
||||
site1.example.net [IPv6-Backend1];
|
||||
site2.example.net [IPv6-Backend2];
|
||||
default [IPv6-Default]:443;
|
||||
```
|
||||
|
||||
### 4.2 TLS SNI-Mapping und TLS-Passthrough
|
||||
|
||||
**Datei:** `/etc/nginx/stream-enabled/443-sni-map.conf`
|
||||
|
||||
```nginx
|
||||
# TLS SNI → Zielbackend:443, basierend auf /etc/nginx/maps/host_upstreams.inc (ohne Port)
|
||||
|
||||
# 1) SNI → IP (ohne Port) laden
|
||||
map $ssl_preread_server_name $upstream_ip_v6 {
|
||||
hostnames;
|
||||
# Zuordnung von URL zu Server-IP für 443 und 80
|
||||
include /etc/nginx/maps/host_upstreams.inc;
|
||||
}
|
||||
|
||||
# 2) IP → IP:443 zusammensetzen
|
||||
map $upstream_ip_v6 $sni_upstream {
|
||||
"~^(.*)$" $1:443;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 0.0.0.0:443;
|
||||
listen [::]:443;
|
||||
|
||||
ssl_preread on;
|
||||
proxy_protocol on;
|
||||
|
||||
proxy_pass $sni_upstream;
|
||||
proxy_connect_timeout 10s;
|
||||
proxy_timeout 180s;
|
||||
|
||||
access_log /var/log/nginx/stream_access.log stream_fmt;
|
||||
error_log /var/log/nginx/stream_error.log warn;
|
||||
}
|
||||
```
|
||||
|
||||
### 4.3 HTTP-ACME-Proxy und Redirect
|
||||
|
||||
**Datei:** `/etc/nginx/conf.d/80-acme-proxy.conf`
|
||||
|
||||
```nginx
|
||||
# 1) Host → IP (ohne Port) aus gemeinsamer Include-Datei
|
||||
map $host $upstream_ip_v6 {
|
||||
hostnames;
|
||||
# Zuordnung für 80 und 443
|
||||
include /etc/nginx/maps/host_upstreams.inc;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 0.0.0.0:80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
|
||||
# 2) ACME-Challenges zum Zielserver auf Port 80
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
proxy_pass http://$upstream_ip_v6:80;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto http;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_connect_timeout 5s;
|
||||
proxy_send_timeout 10s;
|
||||
proxy_read_timeout 10s;
|
||||
}
|
||||
|
||||
# 3) Alles andere auf HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4.4 Apache-Konfiguration (Backend-Server)
|
||||
|
||||
**Datei:** `/etc/apache2/conf-available/10-remoteip-proxyproto.conf`
|
||||
|
||||
```apache
|
||||
RemoteIPProxyProtocol On
|
||||
RemoteIPTrustedProxy <EDGE_PROXY_IPV4>
|
||||
RemoteIPTrustedProxy <EDGE_PROXY_IPV6>
|
||||
LogFormat "%a %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined_realip
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined_realip
|
||||
```
|
||||
|
||||
**Hinweise:**
|
||||
|
||||
- `<EDGE_PROXY_IPV4>` und `<EDGE_PROXY_IPV6>` mit tatsächlichen Adressen des Edge-Proxy ersetzen.
|
||||
- Der Edge-Proxy muss das PROXY-Protokoll aktiv übergeben.
|
||||
- Keine gleichzeitige Verwendung von `RemoteIPHeader`.
|
||||
- Aktivierung:
|
||||
```bash
|
||||
a2enmod remoteip
|
||||
a2enconf 10-remoteip-proxyproto
|
||||
systemctl reload apache2
|
||||
```
|
||||
|
||||
## 5. WireGuard-Konfiguration (Deutsch)
|
||||
|
||||
### 5.1 Schlüsselgenerierung
|
||||
|
||||
Schlüsselgenerierung (pro System eindeutige Dateinamen verwenden, z. B. für Edge-Proxy und jeden Client separat):
|
||||
|
||||
```bash
|
||||
# Edge-Proxy
|
||||
umask 077
|
||||
wg genkey > /etc/wireguard/edgeproxy.key
|
||||
wg pubkey < /etc/wireguard/edgeproxy.key > /etc/wireguard/edgeproxy.key.pub
|
||||
|
||||
# Client 1
|
||||
umask 077
|
||||
wg genkey > /etc/wireguard/client1.key
|
||||
wg pubkey < /etc/wireguard/client1.key > /etc/wireguard/client1.key.pub
|
||||
|
||||
# Für weitere Clients jeweils eindeutige Namen verwenden (client2.key, client3.key, ...)
|
||||
wg genkey > /etc/wireguard/client2.key
|
||||
wg pubkey < /etc/wireguard/client2.key > /etc/wireguard/client2.key.pub
|
||||
```
|
||||
|
||||
### 5.2 Konfiguration Edge-Proxy
|
||||
|
||||
**Datei:** `/etc/wireguard/wg0.conf`
|
||||
|
||||
```ini
|
||||
[Interface]
|
||||
Address = 10.10.10.1/24
|
||||
PrivateKey = <EdgeProxyPrivateKey>
|
||||
ListenPort = 51820
|
||||
PostUp = iptables -t nat -A POSTROUTING -s 10.10.10.0/24 -o <PublicInterface> -j MASQUERADE
|
||||
PostDown = iptables -t nat -D POSTROUTING -s 10.10.10.0/24 -o <PublicInterface> -j MASQUERADE
|
||||
|
||||
[Peer]
|
||||
PublicKey = <Client1PublicKey>
|
||||
AllowedIPs = 10.10.10.2/32
|
||||
|
||||
# Beispiel: zweiter Peer (Client 2)
|
||||
[Peer]
|
||||
PublicKey = <Client2PublicKey>
|
||||
AllowedIPs = 10.10.10.3/32
|
||||
```
|
||||
|
||||
### 5.3 Konfiguration Client 1
|
||||
|
||||
**Datei:** `/etc/wireguard/wg0.conf`
|
||||
|
||||
```ini
|
||||
[Interface]
|
||||
Address = 10.10.10.2/32
|
||||
PrivateKey = <Client1PrivateKey>
|
||||
MTU = 1420
|
||||
|
||||
[Peer]
|
||||
PublicKey = <EdgeProxyPublicKey>
|
||||
Endpoint = [IPv6-Adresse-EdgeProxy]:51820
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
PersistentKeepalive = 25
|
||||
|
||||
# Optional: zweiter Peer (z. B. Backup-Edge-Proxy)
|
||||
[Peer]
|
||||
PublicKey = <EdgeProxyBackupPublicKey>
|
||||
Endpoint = [IPv6-Adresse-EdgeProxy-Backup]:51820
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
PersistentKeepalive = 25
|
||||
```
|
||||
Reference in New Issue
Block a user