On suppose que Nextcloud est fonctionnel en acces direct sur HTTPS. L'objectif est de ne plus exposer Nextcloud directement mais derriere un reverseproxy NGINX. Nextcloud a un certificat autosigné par défaut de apache, donc pas de certificat officiel ( comme Let’s Encrypt)
pas besoin de reverse proxy voir le bonus du post sur le reverse proxy
le virtualhost HTTPS (example):
<VirtualHost *:443>
DocumentRoot /var/www/nextcloud/
ServerName nextcloud.beemoon.fr
Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
</VirtualHost>
Mon environnement:
Après avoir configuré le reverse proxy pour une redirection HTTPS, ajoutez dans config.php à la variable $CONFIG
vi /var/www/nextcloud/config/config.php
$CONFIG = array (
...,
'trusted_domains' =>
array (
0 => '192.168.2.200',
1 => 'nextcloud.beemoon.fr',
),
array (
'trusted_proxies' => ['192.168.2.10'],
'overwritehost' => 'nextcloud.beemoon.fr',
'overwriteprotocol' => 'https',
'overwritecondaddr' => '^192\.168\.2\.10$',
'overwrite.cli.url' => 'https://nextcloud.beemoon.fr',
),
);
Recharger apache et/ou si vous etes avec php-fpm le redémarrer le aussi
systemctl reload apache2 systemctl restart php8.4-fpm.service