bisher habe ich zwei Wordpress Seiten, Nextcloud, Matrix und Datenbank auf einer VM betrieben.
Fritzbox hat alle notwendigen Ports direkt auf die VM verwiesen. Aber es ist mir alles extrem unübersichtlich und chaotisch geworden. (vllt auch gefährlich?)
Jetzt will ich es in verschieden VMs unterteilen. Die VM, auf die Fritzbox verweisen soll, ist die VM DMMNN (Debian-Minimal-mit-nur-Nginx)
VM DMMNN:
Code: Alles auswählen
cat /etc/network/interfaces
allow-hotplug ens32
iface ens32 inet static
address 192.168.178.10/24
gateway 192.168.178.1
nginx.conf
Code: Alles auswählen
cat /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
include /etc/nginx/passthrough.conf;
Code: Alles auswählen
cat /etc/nginx/passthrough.conf
stream {
upstream wp1 {
server 192.168.178.11:80 max_fails=3 fail_timeout=10s;
server 192.168.178.11:443 max_fails=3 fail_timeout=10s;
}
upstream wp2 {
server 192.168.178.12:80 max_fails=3 fail_timeout=10s;
server 192.168.178.12:443 max_fails=3 fail_timeout=10s;
}
upstream nc {
server 192.168.178.13:80 max_fails=3 fail_timeout=10s;
server 192.168.178.13:443 max_fails=3 fail_timeout=10s;
}
upstream matrix {
server 192.168.178.14:80 max_fails=3 fail_timeout=10s;
server 192.168.178.14:443 max_fails=3 fail_timeout=10s;
}
map $ssl_preread_server_name $upstream {
wp1.mydomain.de wp1;
wp2.mydomain.de wp2;
matrix.mydomain.de matrix;
default nc;
}
log_format basic '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log /var/log/nginx/access.log basic;
error_log /var/log/nginx/error.log;
server {
listen 443;
proxy_pass $upstream;
proxy_next_upstream on;
ssl_preread on;
tcp_nodelay on;
}
log_format proxy '$protocol $status $bytes_sent $bytes_received $session_time';
access_log /var/log/nginx/access.log proxy;
error_log /var/log/nginx/error.log debug;
}
Code: Alles auswählen
cat /etc/nginx/sites-available
#WP1 -- brauche ich das überhaupt???
server {
#listen 80;
server_name wp1.mydomain.de;
location / {
proxy_pass http://192.168.178.11;
# Proxy headers
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 timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
client_max_body_size 0;
}
Aber warum muss in sites-enabled überhaupt was drin sein, wenn passthrough.conf schon anweist?
VM wp1 (192.168.178.11)
Code: Alles auswählen
cat /etc/nginx/sites-available/wp1
server {
listen 80 default_server;
set_real_ip_from 192.168.178.10; #klappt nicht, in den logs sehe ich bei zugriff immer nur die ip 192.168.178.10 und nicht die eigentliche Quell-IP
root /var/www/wp1;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
server {
set_real_ip_from 192.168.178.10; #klappt nicht, in den logs sehe ich bei zugriff immer nur die ip 192.168.178.10 und nicht die eigentliche Quell-IP
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name wp1.mydomain.de; # managed by Certbot
location / {
try_files $uri $uri/ =404;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/wp1.mydomain.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/wp1.mydomain.de/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = wp1.mydomain.de) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
server_name wp1.mydomain.de;
return 404; # managed by Certbot
}
vm wp2 schaut identischen aus (natürlich andere ip und hostname)
vm nc mit nginx wird neu aufgesetzt (quelle https://github.com/criegerde/nextcloud/ ... -push.conf).
Fritzbox wird 8008 und 8448 natürlich auf vm matrix leiten.
Alle 4 VMs sind extern erreichbar. Auf allen 4 ist nur nginx drauf + Certbot
Frage: ist das sicher(er)?
Wird es im Realbetrieb funktionieren?
Zusatzfrage: Sollte ich eine VM Datenbank erstellen, auf die alle VMs zugreifen (wp,nc,matrix) oder soll ich in jeder vm eine separate DB installieren?
Bin mit VMs vertraut. Habe mit Docker, Proxmox und konsorten keine Erfahrung.
Freue mich über Hilfe und Tipps
LG