diff --git a/README.md b/README.md new file mode 100644 index 0000000..75148f7 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Installation de l'infrastructure + +### Lancement + +#### Certs + +Au premier lancement, assurez-vous que : + +- Le dossier `/DATA/docker/traefik/certs` existe +- Créez un fichier `acme.json` à l'intérieur +- Changez son propriétaire à `root` +- Changez ses permissions à `600` + +C'est dans ce fichier que seront conservés tous les certificats générés par Traefik. + +### Migration des données + +1. Mettre nextcloud en mode maintenance :  +``` +sudo -u www-data php occ maintenance:mode --on +``` +2. Faire un dump de la bdd +``` +sudo -u postgres pg_dump -Fc nc > nc.dump +``` +3. Sauver les données du dossier nextcloud +``` +mkdir /var/lib/backuppc/migration +tar caf /var/lib/backuppc/migration/nextcloud.tar.xz /srv/nextcloud/ +``` +4. Sauver le fichier de configuration de nextcloud +``` +# par précaution, ne devrait pas être utile +cp /var/www/nextcloud/public_html/config/config.php /var/lib/backuppc/migration +``` + diff --git a/nextcloud-pica/README.md b/nextcloud-pica/README.md deleted file mode 100644 index 154ef2a..0000000 --- a/nextcloud-pica/README.md +++ /dev/null @@ -1,39 +0,0 @@ -## NextCloud - -Ce dossier contient les ressources nécessaires pour lancer une ou plusieurs instances NextCloud. - -Voir également le [wiki](https://wiki.picasoft.net/doku.php?id=technique:adminserv:nextcloud). - -### Configuration - -Quasiment aucune configuration n'est effectuée via les fichiers de ce dépôt, et on préfère l'interface web. -Le défaut est qu'il n'est pas possible de lancer des instances NextCloud **vraiment** personnalisées depuis ce dépôt, mais c'est parce que le format des fichiers de configuration est amené à évoluer et que NextCloud effectue des migrations automatiques lors des mises à jour. - -Versionner les fichiers de configuration serait donc en conflit avec les modifications automatiques effectuées par NextCloud lors des mises à jour et des changements dans l'interface. - -Les fichiers `nginx.conf` sont repris de [cet exemple](https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf). - -### Lancement - -Copier les fichiers `.secrets.example` en `.secrets` et remplacer les valeurs. -Lancer `docker-compose up -d`. - -### Mise à jour - -Pour mettre à jour l'instance de Picasoft, il suffit de mettre à jour le tag de l'image officielle de NextCloud. - -Attention : **toutes les mises à jour de version majeure doivent se faire une par une**. Les logs applicatifs détaillent la mise à jour. -Exemple : -* 15 -> 16, puis -* 16 -> 17, puis -* 17 -> 18. - -Sinon, il y a risque de casse. - -### Mise à jour de MariaDB - -[Selon la documentation](https://mariadb.com/kb/en/upgrading-between-major-mariadb-versions/) : - -> MariaDB is designed to allow easy upgrades. You should be able to trivially upgrade from ANY earlier MariaDB version to the latest one (for example MariaDB 5.5.x to MariaDB 10.5.x), usually in a few seconds. - -L'idée est d'éteindre le conteneur applicatif (NextCloud), puis de lancer la nouvelle version du conteneur, d'entrer dedans, de lancer la commande `mysql_upgrade` et de redémarrer le conteneur. diff --git a/nextcloud-pica/nginx.conf b/nextcloud-pica/nginx.conf deleted file mode 100644 index 3cd205c..0000000 --- a/nextcloud-pica/nginx.conf +++ /dev/null @@ -1,182 +0,0 @@ -worker_processes auto; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - - -events { - worker_connections 1024; -} - - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - set_real_ip_from 10.0.0.0/8; - set_real_ip_from 172.16.0.0/12; - set_real_ip_from 192.168.0.0/16; - real_ip_header X-Real-IP; - - #gzip on; - - upstream php-handler { - server nextcloud-app:9000; - } - - server { - listen 80; - -# HSTS settings - # WARNING: Only add the preload option once you read about - # the consequences in https://hstspreload.org/. This option - # will add the domain to a hardcoded list that is shipped - # in all major browsers and getting removed from this list - # could take several months. - #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; - - # set max upload size and increase upload timeout: - client_max_body_size 512M; - client_body_timeout 300s; - fastcgi_buffers 64 4K; - - # Enable gzip but do not remove ETag headers - gzip on; - gzip_vary on; - gzip_comp_level 4; - gzip_min_length 256; - gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; - gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; - - # Pagespeed is not supported by Nextcloud, so if your server is built - # with the `ngx_pagespeed` module, uncomment this line to disable it. - #pagespeed off; - - # HTTP response headers borrowed from Nextcloud `.htaccess` - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Download-Options "noopen" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "none" always; - add_header X-XSS-Protection "1; mode=block" always; - - # Remove X-Powered-By, which is an information leak - fastcgi_hide_header X-Powered-By; - - # Path to the root of your installation - root /var/www/html; - - # Specify how to handle directories -- specifying `/index.php$request_uri` - # here as the fallback means that Nginx always exhibits the desired behaviour - # when a client requests a path that corresponds to a directory that exists - # on the server. In particular, if that directory contains an index.php file, - # that file is correctly served; if it doesn't, then the request is passed to - # the front-end controller. This consistent behaviour means that we don't need - # to specify custom rules for certain paths (e.g. images and other assets, - # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus - # `try_files $uri $uri/ /index.php$request_uri` - # always provides the desired behaviour. - index index.php index.html /index.php$request_uri; - - # Rule borrowed from `.htaccess` to handle Microsoft DAV clients - location = / { - if ( $http_user_agent ~ ^DavClnt ) { - return 302 /remote.php/webdav/$is_args$args; - } - } - - location = /robots.txt { - allow all; - log_not_found off; - access_log off; - } - - # Make a regex exception for `/.well-known` so that clients can still - # access it despite the existence of the regex rule - # `location ~ /(\.|autotest|...)` which would otherwise handle requests - # for `/.well-known`. - location ^~ /.well-known { - # The rules in this block are an adaptation of the rules - # in `.htaccess` that concern `/.well-known`. - - location = /.well-known/carddav { return 301 /remote.php/dav/; } - location = /.well-known/caldav { return 301 /remote.php/dav/; } - - location /.well-known/acme-challenge { try_files $uri $uri/ =404; } - location /.well-known/pki-validation { try_files $uri $uri/ =404; } - - # Let Nextcloud's API for `/.well-known` URIs handle all other - # requests by passing them to the front-end controller. - return 301 /index.php$request_uri; - } - - # Rules borrowed from `.htaccess` to hide certain paths from clients - location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } - location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } - - # Ensure this block, which passes PHP files to the PHP process, is above the blocks - # which handle static assets (as seen below). If this block is not declared first, - # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` - # to the URI, resulting in a HTTP 500 error response. - location ~ \.php(?:$|/) { - # Required for legacy support - rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri; - - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - set $path_info $fastcgi_path_info; - - try_files $fastcgi_script_name =404; - - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $path_info; - fastcgi_param HTTPS on; - - fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice - fastcgi_param front_controller_active true; # Enable pretty urls - fastcgi_pass php-handler; - - fastcgi_intercept_errors on; - fastcgi_request_buffering off; - - fastcgi_max_temp_file_size 0; - } - - location ~ \.(?:css|js|svg|gif|png|jpg|ico|wasm|tflite|map)$ { - try_files $uri /index.php$request_uri; - expires 6M; # Cache-Control policy borrowed from `.htaccess` - access_log off; # Optional: Don't log access to assets - - location ~ \.wasm$ { - default_type application/wasm; - } - } - - location ~ \.woff2?$ { - try_files $uri /index.php$request_uri; - expires 7d; # Cache-Control policy borrowed from `.htaccess` - access_log off; # Optional: Don't log access to assets - } - - # Rule borrowed from `.htaccess` - location /remote { - return 301 /remote.php$request_uri; - } - - location / { - try_files $uri $uri/ /index.php$request_uri; - } -} -} diff --git a/nextcloud-pica/secrets/pica.secrets.example b/nextcloud-pica/secrets/pica.secrets.example deleted file mode 100644 index f50e981..0000000 --- a/nextcloud-pica/secrets/pica.secrets.example +++ /dev/null @@ -1,4 +0,0 @@ -MYSQL_ROOT_PASSWORD=password -MYSQL_DATABASE=nextcloud -MYSQL_USER=nextcloud -MYSQL_PASSWORD=password diff --git a/nextcloud-pica/zz-php-custom.ini b/nextcloud-pica/zz-php-custom.ini deleted file mode 100644 index e69de29..0000000 diff --git a/nextcloud-pica/zz-php-fpm-custom.conf b/nextcloud-pica/zz-php-fpm-custom.conf deleted file mode 100644 index f72bd38..0000000 --- a/nextcloud-pica/zz-php-fpm-custom.conf +++ /dev/null @@ -1,7 +0,0 @@ -[www] -pm = dynamic -pm.max_children = 50 -pm.start_servers = 15 -pm.min_spare_servers = 15 -pm.max_spare_servers = 25 -pm.max_requests = 500 diff --git a/nextcloud-pica/.gitignore b/nextcloud/.gitignore similarity index 100% rename from nextcloud-pica/.gitignore rename to nextcloud/.gitignore diff --git a/nextcloud-pica/.nginx.conf.swp b/nextcloud/.nginx.conf.swp similarity index 100% rename from nextcloud-pica/.nginx.conf.swp rename to nextcloud/.nginx.conf.swp diff --git a/nextcloud-pica/docker-compose.yml b/nextcloud/docker-compose.yml similarity index 72% rename from nextcloud-pica/docker-compose.yml rename to nextcloud/docker-compose.yml index dca2461..58a3522 100644 --- a/nextcloud-pica/docker-compose.yml +++ b/nextcloud/docker-compose.yml @@ -13,46 +13,28 @@ networks: services: nextcloud-app: - image: nextcloud:23.0.4-fpm-alpine + image: nextcloud:23.0 container_name: nextcloud-app restart: unless-stopped volumes: - nextcloud:/var/www/html - - ./zz-php-custom.ini:/usr/local/etc/php/conf.d/zz-php-custom.ini - - ./zz-php-fpm-custom.conf:/usr/local/etc/php-fpm.d/zz-php-custom.conf + #- ./config.php:/var/www/html/config/config.php + #- ./zz-php-custom.ini:/usr/local/etc/php/conf.d/zz-php-custom.ini + #- ./zz-php-fpm-custom.conf:/usr/local/etc/php-fpm.d/zz-php-custom.conf environment: - "TZ=Europe/Paris" - - POSTGRES_HOST=nextcloud-db - REDIS_HOST=redis env_file: ./secrets/librezo.secrets - extra_hosts: - - code.librezo.xyz:192.168.1.70 depends_on: - nextcloud-db - redis - networks: - - nextcloud - restart: unless-stopped - - nextcloud-web: - image: nginx:alpine - container_name: nextcloud-web - volumes: - - nextcloud:/var/www/html:ro - - ./nginx.conf:/etc/nginx/nginx.conf:ro - env_file: ./secrets/librezo.secrets - extra_hosts: - - code.librezo.xyz:192.168.1.70 - depends_on: - - nextcloud-app - environment: - TZ: Europe/Paris networks: - nextcloud - proxy + restart: unless-stopped labels: traefik.http.routers.nextcloud-web.entrypoints: websecure - traefik.http.routers.nextcloud-web.rule: Host(`cloud.librezo.xyz`) + traefik.http.routers.nextcloud-web.rule: Host(`cloud.oasis21.org`) traefik.http.services.nextcloud-web.loadbalancer.server.port: 80 traefik.enable: true # https://docs.nextcloud.com/server/16/admin_manual/configuration_server/reverse_proxy_configuration.html @@ -88,27 +70,31 @@ services: collabora: image: libreoffice/online:master container_name: collabora + volumes: + - ./loolwsd.xml:/etc/loolwsd/loolwsd.xml + #- ./zz-php-fpm-custom.conf:/usr/local/etc/php-fpm.d/zz-php-custom.conf # ports: # - 9980:9980 # expose: # - "9980" environment: - "TZ=Europe/Paris" - - domain=cloud\.librezo\.xyz - - username=nextcloud - - password=password - - serveur_name=code\.librezo\.xyz + - domain=cloud\.calad\.re +# - username=${COLLABORA_USER} +# - password=${COLLABORA_PASSWORD} + - serveur_name=code\.calad\.re - "extra_params=--o:ssl.enable=false --o:ssl.termination=true" networks: - nextcloud - proxy + env_file: ./secrets/librezo.secrets cap_add: - MKNOD restart: unless-stopped labels: traefik.http.routers.collabora.entrypoints: websecure - traefik.http.routers.collabora.rule: Host(`code.librezo.xyz`) + traefik.http.routers.collabora.rule: Host(`code.oasis21.org`) traefik.http.services.collabora.loadbalancer.server.port: 9980 traefik.enable: true diff --git a/nextcloud/loolwsd.xml b/nextcloud/loolwsd.xml new file mode 100644 index 0000000..1fd2e18 --- /dev/null +++ b/nextcloud/loolwsd.xml @@ -0,0 +1,166 @@ + + + + + + en_GB en_US fr_FR + + + + + code.oasis21.org + + + + 1 + + 4 + 5 + + false + 3600 + + + 30 + 300 + false + 0 + 8000 + 0 + 0 + 100 + 100 + + + + 120 + 900 + + + loleaflet.html + + + true + debug + true + + /var/log/loolwsd.log + 50M + timestamp + true + 10 days + 10 + true + false + + + false + 82589933 + + + + false + + + + + + + + false + + + + + + all + any + + + + 192\.168\.[0-9]{1,3}\.[0-9]{1,3} + ::ffff:192\.168\.[0-9]{1,3}\.[0-9]{1,3} + 127\.0\.0\.1 + ::ffff:127\.0\.0\.1 + ::1 + 172\.17\.[0-9]{1,3}\.[0-9]{1,3} + ::ffff:172\.17\.[0-9]{1,3}\.[0-9]{1,3} + + cloud.oasis21.org + + + + true + true + /etc/loolwsd/cert.pem + /etc/loolwsd/key.pem + /etc/loolwsd/ca-chain.cert.pem + + + 1000 + + + + + + + + + true + true + + + + + + + + + false + false + + + + + + + cloud.oasis21.org + 10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} + 172\.1[6789]\.[0-9]{1,3}\.[0-9]{1,3} + 172\.2[0-9]\.[0-9]{1,3}\.[0-9]{1,3} + 172\.3[01]\.[0-9]{1,3}\.[0-9]{1,3} + 192\.168\.[0-9]{1,3}\.[0-9]{1,3} + 192\.168\.1\.1 + 0 + false + + 900 + + + + cloud.oasis21.org + + + true + + + + + + + + + true + + + true + false + nextcloud + o!NdFB7fpQAbXG + + + + + + diff --git a/nextcloud/secrets/librezo.secrets.example b/nextcloud/secrets/librezo.secrets.example new file mode 100644 index 0000000..34115af --- /dev/null +++ b/nextcloud/secrets/librezo.secrets.example @@ -0,0 +1,6 @@ +POSTGRES_PASSWORD=__POSTGRES_PASSWORD__ +POSTGRES_DB=nc +POSTGRES_USER=nc +POSTGRES_HOST=nextcloud-db +username=nextcloud +password=__COLLABORA_PASSWORD__ diff --git a/traefik/docker-compose.yml b/traefik/docker-compose.yml index 3cfb9b2..73681cf 100644 --- a/traefik/docker-compose.yml +++ b/traefik/docker-compose.yml @@ -6,27 +6,18 @@ networks: services: traefik: - image: traefik:2.6 + image: traefik:2.5 container_name: traefik ports: - 80:80 - 443:443 - - 8080:8080 volumes: - /var/run/docker.sock:/var/run/docker.sock - ./traefik.toml:/traefik.toml - ./traefik_dynamic.toml:/traefik_dynamic.toml - - /DATA/docker/traefik/certs:/certs + - /DATA/docker/services/certs:/certs environment: TZ: Europe/Paris -# labels: -# traefik.http.routers.traefik-metrics.entrypoints: websecure -# traefik.http.routers.traefik-metrics.rule: "Host(`${SERVER_NAME}`) && PathPrefix(`/metrics`)" -# traefik.http.routers.traefik-metrics.service: traefik-metrics -# traefik.http.routers.traefik-metrics.middlewares: "traefik-metrics-auth@docker" -# traefik.http.middlewares.traefik-metrics-auth.basicauth.users: "${METRICS_AUTH}" -# traefik.http.services.traefik-metrics.loadbalancer.server.port: 8082 -# traefik.enable: true networks: - proxy restart: unless-stopped diff --git a/traefik/traefik.toml b/traefik/traefik.toml index 38c194c..6b8ab4f 100644 --- a/traefik/traefik.toml +++ b/traefik/traefik.toml @@ -13,27 +13,24 @@ [entryPoints.websecure.http] middlewares = ["hardening@file", "compression@file"] [entryPoints.websecure.http.tls] -# certResolver = "letsencrypt" + certResolver = "letsencrypt" options = "tls12@file" - # [entryPoints.metrics] - # address = ":8082" + [entryPoints.metrics] + address = ":8082" [providers] providersThrottleDuration = "2s" [providers.docker] watch = true endpoint = "unix:///var/run/docker.sock" - exposedByDefault = true + exposedByDefault = false network = "proxy" [providers.file] filename = "/traefik_dynamic.toml" watch = true -[api] - insecure = true - [log] - level = "DEBUG" + level = "INFO" [accessLog] format = "json" @@ -44,14 +41,10 @@ "StartUTC" = "drop" "ClientUsername" = "drop" -#[certificatesResolvers] -# [certificatesResolvers.letsencrypt] -# [certificatesResolvers.letsencrypt.acme] -# email = "picasoft@assos.utc.fr" -# storage = "/certs/acme.json" -# [certificatesResolvers.letsencrypt.acme.httpChallenge] -# entryPoint = "web" - -#[metrics] -# [metrics.prometheus] -# entryPoint = "metrics" +[certificatesResolvers] + [certificatesResolvers.letsencrypt] + [certificatesResolvers.letsencrypt.acme] + email = "serveur@oasis21.org" + storage = "/certs/acme.json" + [certificatesResolvers.letsencrypt.acme.httpChallenge] + entryPoint = "web" diff --git a/website/.gitignore b/website/.gitignore deleted file mode 100644 index 5911da2..0000000 --- a/website/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.secrets -.env -certs diff --git a/website/docker-compose.yml b/website/docker-compose.yml deleted file mode 100644 index fc76268..0000000 --- a/website/docker-compose.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: "3.7" - -volumes: - website: - name: website - -networks: - proxy: - external: true - -services: - website: - container_name: website - image: nginx:1.21-alpine - volumes: - - website:/usr/share/nginx/html - labels: - traefik.http.routers.website.entrypoints: web, websecure - traefik.http.routers.website.rule: Host(`www.librezo.xyz`) - traefik.http.services.website.loadbalancer.server.port: 80 - traefik.enable: true - networks: - - proxy - restart: unless-stopped diff --git a/website/index.html b/website/index.html deleted file mode 100644 index c4f03c3..0000000 --- a/website/index.html +++ /dev/null @@ -1,7 +0,0 @@ - - -le monocycle c'est la vie - - - -