Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tech:web-01 [18/09/2025 00:04] – [Stockage] LibertAdmintech:web-01 [14/10/2025 08:15] (Version actuelle) – [Liberta (Site principal)] LibertAdmin
Ligne 1176: Ligne 1176:
 </code> </code>
  
 +==== Partie logicielle ====
 +
 +Toutes les applications web des services sont servies par le serveur / reverse-proxy Nginx dont voici les configurations pour chaque application ainsi que les configurations communes.
 +
 +Nous avons décidé de bannir dans la configuration générale un certain nombre de pays nous noyant de spam et d'attaques en tout genre :
 +
 +<code bash>
 +# cat /etc/nginx/nginx.conf
 +user www-data;
 +worker_processes auto;
 +pid /run/nginx.pid;
 +include /etc/nginx/modules-enabled/*.conf;
 +
 +events {
 + worker_connections 1024;
 + multi_accept on;
 + use epoll;
 +}
 +
 +http {
 + server_names_hash_bucket_size 64;
 +
 + # Liberta : no more reverse proxy:
 + #set_real_ip_from 127.0.0.1;
 + #set_real_ip_from 192.168.10.0/24;
 + #real_ip_header X-Forwarded-For;
 + #real_ip_recursive on;
 +
 + include /etc/nginx/mime.types;
 + default_type application/octet-stream;
 + access_log /var/log/nginx/access.log;
 + error_log /var/log/nginx/error.log warn;
 + sendfile on;
 + send_timeout 3600;
 + tcp_nopush on;
 + tcp_nodelay on;
 + open_file_cache max=500 inactive=10m;
 + open_file_cache_errors on;
 + keepalive_timeout 65;
 + reset_timedout_connection on;
 + server_tokens off;
 + resolver_timeout 5s;
 + proxy_buffers 16 16k;
 + proxy_buffer_size 16k;
 + fastcgi_buffers 64 4K;
 + client_max_body_size 8G;
 +
 + ##
 + # Logging Settings
 + ##
 +
 + rewrite_log on;
 + access_log /var/log/nginx/access.log;
 + error_log /var/log/nginx/error.log notice;
 +
 + # Liberta : ban all countries except those:
 + geoip_country /usr/share/GeoIP/GeoIP.dat;
 + map $geoip_country_code $allowed_country {
 +         default no;
 +         AL yes;
 +         AD yes;
 +         AM yes;
 +         AT yes;
 +         BA yes;
 +         BE yes;
 +         BG yes;
 +         BY yes;
 +         CH yes;
 +         CY yes;
 +         CZ yes;
 +         DK yes;
 +         EE yes;
 +         FI yes;
 +         FR yes;
 +         FO yes;
 +         DE yes;
 +         GB yes;
 +         GE yes;
 +         GI yes;
 +         GR yes;
 +         HR yes;
 +         HU yes;
 +         IE yes;
 +         IM yes;
 +         IS yes;
 +         IT yes;
 +         LI yes;
 +         LV yes;
 +         LT yes;
 +         LU yes;
 +         MC yes;
 +         MD yes;
 +         ME yes;
 +         MK yes;
 +         MT yes;
 +         NL yes;
 +         NO yes;
 +         PL yes;
 +         PT yes;
 +         RO yes;
 +         SK yes;
 +         SI yes;
 +         ES yes;
 +         RS yes;
 +         RU yes;
 +         SE yes;
 +         SM yes;
 +         TR yes;
 +         UA yes;
 +         VA yes;
 +         XK yes;
 + # Allowed countries list:
 + # AL,AD,AM,AT,BA,BE,BG,BY,CH,CY,CZ,DK,EE,FI,FR,FO,DE,GB,GE,GI,GR,HR,HU,IE,IM,IS,IT,LI,LV,LT,LU,MC,MD,ME,MK,MT,NL,NO,PL,PT,RO,SK,SI,ES,RS,RU,SE,SM,TR,UA,VA,XK
 + }
 +
 + ##
 + # Virtual Host Configs
 + ##
 +
 + include /etc/nginx/conf.d/*.conf;
 + include /etc/nginx/sites-enabled/*;
 +}
 +</code>
 +
 +Nous avons créé le fichier commun ''/etc/nginx/letsencrypt_security.conf'' afin de pouvoir générer et renouveler facilement des certificats TLS Let's Encrypt pour chacune de nos applications web. 
 +
 +Le fichier est agrémenté de directives de sécurité recommandées pour la plupart des applications (certaines modifient ces directives via leur propre configuration évidemment) :
 +
 +<code bash>
 +# cat /etc/nginx/letsencrypt_security.conf 
 +# Security headers
 +add_header X-XSS-Protection          "1; mode=block" always;
 +add_header X-Content-Type-Options    "nosniff" always;
 +add_header Referrer-Policy           "no-referrer-when-downgrade" always;
 +add_header Content-Security-Policy   "default-src 'self' http: https: ws: wss: data: blob: 'unsafe-inline'; frame-ancestors 'self';" always;
 +add_header Permissions-Policy        "interest-cohort=()" always;
 +add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
 +
 +# Dotfiles
 +location ~ /\.(?!well-known) {
 + deny all;
 +}
 +
 +# ACME-challenge
 +location ^~ /.well-known/acme-challenge/ {
 + root /var/www/_letsencrypt;
 +}
 +</code>
 +
 +
 +=== Liberta (Site principal)===
 +
 +Le site de Liberta est en pur HTML et CSS. Il **était**, il est passé sur [[https://ghost.org/|Ghost]] en septembre 2025. Néanmoins nous laissons ici la doc originelle pour totu besoin pédagogique.
 +
 +Ce fichier contient la gestion globale du HTTP, lequel redirige tous les domaines vers HTTPS, notamment le site de Liberta qui est sur le sous-domaine ''www.''
 +
 +Nous listons volontairement notre répertoire ''img/'' pour exposer nos images et pouvoir les utiliser facilement pour les includre sur nos pages ; c'est notamment utile pour insérer des images sur notre blog (WriteFreely ne le permet pas dans sa version communautaire malheureusement) :
 +
 +<code bash>
 +# Configuration globale :
 +# HTTP + redirect
 +server {
 + server_name _;
 + listen      80;
 + listen      [::]:80;
 +
 + include letsencrypt_security.conf;
 +
 + location / {
 + return 301 https://$host$request_uri;
 + }
 +}
 +
 +# Domaine liberta.vip sans sous-domaine :
 +# HTTP + redirect
 +server {
 + server_name liberta.vip;
 + listen      80;
 + listen      [::]:80;
 +
 + include letsencrypt_security.conf;
 +
 + location / {
 + return 301 https://www.$host$request_uri;
 + }
 +}
 +server {
 +        server_name liberta.vip;
 +        listen 443 ssl http2;
 +        listen [::]:443 ssl http2;
 +        ssl_certificate /etc/letsencrypt/live/liberta.vip-0001/fullchain.pem;
 +        ssl_certificate_key /etc/letsencrypt/live/liberta.vip-0001/privkey.pem;
 +        return 301 https://www.liberta.vip;
 +}
 +# Liberta (Pur HTML / CSS)
 +# HTTP + redirect
 +server {
 +        server_name www.liberta.vip;
 +        listen      80;
 +        listen      [::]:80;
 +
 + include letsencrypt_security.conf;
 +
 +        location / {
 +                return 301 https://$host$request_uri;
 +        }
 +}
 +server {
 +        server_name www.liberta.vip;
 +        listen 443 ssl http2;
 +        listen [::]:443 ssl http2;
 +        ssl_certificate /etc/letsencrypt/live/liberta.vip-0001/fullchain.pem;
 +        ssl_certificate_key /etc/letsencrypt/live/liberta.vip-0001/privkey.pem;
 +
 +        # Secure headers
 +        add_header X-Frame-Options "SAMEORIGIN" always;
 +        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
 +        add_header X-Xss-Protection "1; mode=block" always;
 +        add_header Content-Security-Policy "default-src 'self' 'unsafe-inline'; script-src www.liberta.vip; img-src *;";
 +        add_header X-Content-Type-Options "nosniff" always;
 +
 +
 +        root /var/www/www.liberta.vip;
 +        access_log /var/log/nginx/www.liberta.vip_access.log;
 +        error_log /var/log/nginx/www.liberta.vip_error.log warn;
 +        index index.html;
 +
 +        location = /favicon.ico {
 +                log_not_found off;
 +                access_log off;
 +        }
 +
 +        location = /robots.txt {
 +                allow all;
 +                log_not_found off;
 +                access_log off;
 +        }
 +        
 + location = /img/ {
 +                allow all;
 +                log_not_found off;
 +                access_log off;
 + autoindex on;
 +        }
 +
 +        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
 +                expires max;
 +                log_not_found off;
 +        }
 +}
 +</code>
 +
 +Nous ne fournirons pas tous les détails des configurations pour chaque application, lesquelles sont souvent appelées à changer lors des mises à jour et rendraient la maintenance de cette documentation fort fastidieuse. 
 +
 +À terme, nous prévoyons de publier notre configuration complète sur [[https://framagit.org/appzer0/liberta/|notre dépôt git]], d'autant plus que nous désirons l'industrialiser / l'automatiser via ''ansible''.
 +
 +EN COURS DE RÉDACTION...
 +=== CryptPad (Liberta Docs)===
 +=== Etherpad-Lite (Liberta Pad) ===
 +=== Funkwhale (Liberta Audio) ===
 +=== Nextcloud (Liberta Cloud) ===
 +=== Peertube (Liberta Vidéo) ===
 +=== WriteFreely (Liberta Blogs) ===