Nextcloud mit swag und collabora Office
Die DNS-Validierung von swag erfolgt mit Hetzner.
Wir gehen folgendermaßen vor:
1) VM erstellen: Erstellen oder mieten Sie eine VM mit Debian 12 Linux
2) Programme nachinstallieren:
apt install sudo curl
adduser admin adduser admin sudo
4) Als Benutzer anmelden, dann Docker installieren und Rechte vergeben
curl -fsSL https://get.docker.com | sh sudo adduser admin docker
5) Abmelden von der VM und neu als admin-Benutzer anmelden damit die docker-Rechte stimmen
6) Im Homeverzeichnis einen Ordner für die docker compose-Dateien anlegen
mkdir nextcloud
7) Darin zwei Dateien anlegen, zuerst die docker compose-Datei
services: nextcloud: image: linuxserver/nextcloud:latest container_name: nextcloud-app environment: - PUID=1000 - PGID=1000 - TZ=Europe/Berlin volumes: - /path/to/nextcloud/config:/config - /path/to/nextcloud/data:/data restart: unless-stopped depends_on: - db - swag db: image: mariadb:latest container_name: nextcloud-db volumes: - /path/to/nextcloud/db:/var/lib/mysql environment: - PUID=1000 - PGID=1000 - TZ=Europe/Berlin - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - MYSQL_DATABASE=${MYSQL_DATABASE} - MYSQL_USER=${MYSQL_USER} - MYSQL_PASSWORD=${MYSQL_PASSWORD} swag: image: linuxserver/swag:latest container_name: nextcloud-swag restart: unless-stopped ports: - 443:443 cap_add: - net_admin environment: - PUID=1000 - PGID=1000 - TZ=Europe/Berlin - EMAIL=Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein. - URL=mydomain.de - SUBDOMAINS=nextcloud,collabora - ONLY_SUBDOMAINS=true - VALIDATION=dns - DNSPLUGIN=hetzner volumes: - /etc/localtime:/etc/localtime:ro - /path/to/nextcloud/swag:/config redis: image: redis:latest container_name: nextcloud-redis command: redis-server --requirepass ${REDIS_PASSWORD} environment: - REDIS_PASSWORD=${REDIS_PASSWORD} volumes: - /path/to/nextcloud/redis:/data restart: unless-stopped collabora: image: collabora/code:latest container_name: nextcloud-collabora environment: - TZ=Europe/Berlin - domain="nextcloud\.mydomain\.de" - dictionaries="de en" ports: - 9980:9980 restart: unless-stopped
8) Jetzt die .env Datei, hier unbedingt die Passwörter anpassen!
MYSQL_ROOT_PASSWORD=aaabbbccc MYSQL_DATABASE=nextcloud MYSQL_USER=nextcloud MYSQL_PASSWORD=dddeeefff REDIS_PASSWORD=ggghhhiii
9) Jetz kann man das Projekt schonmal starten
docker compose up -d
10) Kurz warten, dann gleich wieder beenden, wir müssen swag ja noch anpassen
docker compose down
11) Jetzt swag anpassen: Dazu ins Verzeichnis /path/to/nextcloud/swag/dns-conf wechseln und in der Datei hetzner.ini den DNS-access token von Hetzner eintragen.
12) Danach ins Verzeichnis /path/to/nextcloud/swag/nginx/proxy-confs wechseln
cp nextcloud.subdomain.conf.sample nextcloud.subdomain.conf
13) Jetzt noch die ssl.conf anpassen, dazu ein Verzeichnis höher wechseln und Kommentare entfernen damit es aktiv wird. Das muss aus Sicherhitsgründen gemacht werden, damit nextcloud später nicht meckert.
# HSTS (ngx_http_headers_module is required) (63072000 seconds) add_header Strict-Transport-Security "max-age=63072000" always; # Optional additional headers add_header Cache-Control "no-transform" always; add_header Content-Security-Policy "upgrade-insecure-requests; frame-ancestors 'self'" always; add_header Permissions-Policy "interest-cohort=()" always; add_header Referrer-Policy "same-origin" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-UA-Compatible "IE=Edge" always; add_header X-XSS-Protection "1; mode=block" always;
14) Die Datei config.php im Verzeichnis /path/to/nextcloud/config/www/nextcloud/config muss angepasst werden, folgendes muss hinzugefügt und angepasst werden falls noch nicht vorhanden
'overwrite.cli.url' => 'https://nextcloud.mydomain.de', 'trusted_domains' => array ( 0 => 'nextcloud.mydomain.de', ), 'default_phone_region' => 'DE', 'trusted_proxies' => [gethostbyname('swag')], 'memcache.local' => '\\OC\\Memcache\\APCu', 'memcache.distributed' => '\\OC\\Memcache\\Redis', 'memcache.locking' => '\\OC\\Memcache\\Redis', 'filelocking.enabled' => true, 'redis' => array ( 'host' => 'redis', 'port' => 6379, 'password' => '<Redis Password from .env file>', ), 'mail_from_address' => 'noreply', 'mail_smtpmode' => 'smtp', 'mail_sendmailmode' => 'smtp', 'mail_domain' => 'mydomain.de', 'mail_smtphost' => 'mail.mydomain.de', 'mail_smtpport' => '587', 'mail_smtpauth' => 1, 'mail_smtpname' => 'mailuser', 'mail_smtppassword' => 'xxxyyyzzz'
14) Das Projekt kann wieder gestartet werden
docker compose up -d
15) Man muss jetzt gut 1 - 2 Minuten warten, bis das Zertifikat ausgestellt ist, dabei kann man die Logdateien kontroliieren
docker logs nextcloud-swag docker logs nextcloud-app docker logs nextcloud-db docker logs nextcloud-collabora
16) Schlußendlich kann man auf die URL von nextcloud zugreiffen: https://nextcloud.mydomain.de
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.
By accepting you will be accessing a service provided by a third-party external to https://neticens.de/