« NextCloud » : différence entre les versions

De Le Wiki de Lug
Aller à la navigation Aller à la recherche
Ligne 152 : Ligne 152 :
   ),
   ),
   'overwritewebroot' => '/',</font>
   'overwritewebroot' => '/',</font>
{{Méta bandeau
  | niveau = information
  | icône = loupe
  | texte  = NextCloud sera maintenant accessible via <font color = green>nextcloud.exemple.com</font>
}}

Version du 13 avril 2021 à 15:20

LXC Ubuntu 20.04

Installation Serveur

Source autre source

# apt update && apt upgrade

Archive NextCloud

Page de téléchargement

# apt install unzip
# cd /tmp/
# wget https://download.nextcloud.com/server/releases/nextcloud-21.0.1.zip
# unzip nextcloud-21.0.1.zip -d /var/www/
# rm nextcloud-21.0.1.zip
# chown -R www-data. /var/www/nextcloud

Serveur SQL MariarDB

Installation :

# apt install mariadb-server

On lance le script pour attribuer un mot de passe root, virer l'utilisateur anonyme etc.

# mysql_secure_installation
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
... Success!

On créé la base de donnée pour NextCloud :

# mysql -U
MariaDB [(none)]> create database nextcloud;
MariaDB [(none)]> create user nextcloud@localhost identified by 'motdepasse';
MariaDB [(none)]> grant all privileges on nextcloud.* to nextcloud@localhost IDENTIFIED BY 'motdepasse';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit;

Installation de Apache2 & PHP7.4

# apt install imagemagick php-imagick libapache2-mod-php7.4 php7.4-common php7.4-mysql php7.4-fpm php7.4-gd php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-bcmath php7.4-gmp

On créé le vhost local :

# vi /etc/apache2/sites-available/nextcloud.conf
Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews

  <IfModule mod_dav.c>
    Dav off
  </IfModule>

</Directory>

On active le site :

# a2ensite nextcloud.conf

On active quelques modules :

# a2enmod rewrite
# a2enmod headers
# a2enmod env
# a2enmod dir
# a2enmod mime

On active SSL :

# a2enmod ssl
# a2ensite default-ssl
# systemctl reload apache2

Configuration de NextCloud

On se rend sur l'adresse https://IP_NEXCLOUD/nextcloud/ et on rempli les champs indiqués puis ont clique sur "Terminer l'installation".

Page d'installation NextCloud

Si message d'erreur pas de panique, on retourne sur https://IP_NEXCLOUD/nextcloud/ pour vérifier que tout s'est bien déroulé.

Page de première connexion.

Configuration Reverse-Proxy NGINX

VHost NextCloud

Exemple de vhost pour NextCloud :

server {
listen 80;
    listen [::]:80;
    server_name     nextcloud.exemple.com;
   # return 404;
    return 301 https://$host$request_uri;
}

server {
server_name     nextcloud.exemple.com;
    error_page 403  https://nextcloud.exemple.com;

    location / {
            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 $scheme;
            proxy_set_header X-Forwarded-Protocol $scheme;
            proxy_set_header X-Forwarded-Host $http_host;
            proxy_pass https://IP_SERVEUR_NEXTCLOUD/nextcloud/;
    }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot


    ssl_certificate /etc/letsencrypt/live/nextcloud.exemple.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nextcloud.exemple.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
    add_header Strict-Transport-Security "max-age=31536000" always;
    ssl_trusted_certificate /etc/letsencrypt/live/nextcloud.exemple.com/chain.pem;
    ssl_stapling on;
    ssl_stapling_verify on;

    location ^~ /.well-known {
        # The following 6 rules are borrowed from `.htaccess`

        location = /.well-known/carddav     { return 301 /remote.php/dav/; }
        location = /.well-known/caldav      { return 301 /remote.php/dav/; }
        # Anything else is dynamically handled by Nextcloud
        location ^~ /.well-known            { return 301 /index.php$uri; }

        try_files $uri $uri/ =404;
    }

}

Configuration de Nextcloud

On modifie le fichier de configuration de NextCloud pour qu'il accepte le nom de domaine et le reverse proxy :

NextCloud ~# vi /var/www/nextcloud/config/config.php
'trusted_domains' =>
 array (
         0 => '12.34.56.789',
         1 => 'nextcloud.exemple.com',
 ),
 'trusted_proxies' =>
 array (
         0 => 'IP_PROXY',
 ),
 'overwritewebroot' => '/',