yunohost_un_container_lxc
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédenteDernière révisionLes deux révisions suivantes | ||
yunohost_un_container_lxc [2020/11/21 16:19] – créée Benjamin Labomedia | yunohost_un_container_lxc [2023/01/25 00:12] – Benjamin Labomedia | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Yunohost dans un container LXC ====== | ====== Yunohost dans un container LXC ====== | ||
- | ===== Configurations spéciales à prendre en compte | + | ===== Installation du container LXC ===== |
+ | Créer le container avec comme nom ynh | ||
+ | lxc-create -n ynh -t download -- -d debian -r buster -a amd64 | ||
+ | La config du container | ||
+ | nano / | ||
+ | <file bash config> | ||
+ | # Template used to create this container: / | ||
+ | # Parameters passed to the template: -d debian -r buster -a amd64 | ||
+ | # Distribution configuration | ||
+ | lxc.include | ||
+ | lxc.arch | ||
+ | # Container specific configuration | ||
+ | lxc.apparmor.profile | ||
+ | lxc.apparmor.allow_nesting | ||
+ | lxc.rootfs.path | ||
+ | lxc.uts.name = ynh | ||
+ | # Network configuration | ||
+ | lxc.net.0.type = veth | ||
+ | lxc.net.0.link = lxcbr0 | ||
+ | lxc.net.0.flags = up | ||
+ | lxc.net.0.hwaddr = 00: | ||
+ | </ | ||
+ | Démarrer le container | ||
+ | lxc-start ynh | ||
+ | Vérifier et lister les container | ||
+ | lxc-ls -f | ||
+ | < | ||
+ | NAME STATE | ||
+ | ynh RUNNING 0 | ||
+ | </ | ||
+ | Entrer dans le container | ||
+ | lxc-attach ynh | ||
+ | root@ynh: | ||
+ | Taper exit pour en sortir | ||
- | ==== Dans le host ==== | + | ===== Configurations complémentaires de l' |
+ | |||
+ | ==== Config LXC ==== | ||
Faire marcher le système de gestion du temps, ajouter une config pour les containers LXC : | Faire marcher le système de gestion du temps, ajouter une config pour les containers LXC : | ||
Yes, every option you place in files you include in / | Yes, every option you place in files you include in / | ||
Ligne 11: | Ligne 46: | ||
lxc.cap.drop = mac_admin mac_override sys_module sys_rawio | lxc.cap.drop = mac_admin mac_override sys_module sys_rawio | ||
Redémarrer le container | Redémarrer le container | ||
+ | lxc-stop ynh | ||
+ | lxc-start ynh | ||
+ | |||
* https:// | * https:// | ||
+ | |||
+ | Voir également les fichiers de config génériques de lxc | ||
+ | nano / | ||
+ | nano / | ||
+ | |||
+ | |||
+ | ==== Apache vhost proxy vers le container ==== | ||
+ | Apache va servir de proxy pour renvoyer le traffic au container yunohost, une fois apache installé, on lui rajoute des bouts | ||
+ | a2enmod expires headers ssl proxy proxy_http proxy_html proxy_wstunnel | ||
+ | Installer un certificat https avec certbot et un vhost type | ||
+ | |||
+ | On constitue ensuite un vhost proxy pour le https, le http redirige systématiquement sur ce vhost, [[https:// | ||
+ | nano / | ||
+ | <file php ynh.futuretic.fr-le-ssl.conf> | ||
+ | < | ||
+ | |||
+ | < | ||
+ | |||
+ | ServerAdmin | ||
+ | ServerName | ||
+ | |||
+ | SSLEngine on | ||
+ | SSLProxyEngine On | ||
+ | # ajout suite a default ssl handshake et suite à AH01097: pass request body failed | ||
+ | SSLProxyVerify none | ||
+ | SSLProxyCheckPeerCN off | ||
+ | SSLProxyCheckPeerName off | ||
+ | SSLProxyCheckPeerExpire off | ||
+ | |||
+ | SSLCertificateFile / | ||
+ | SSLCertificateKeyFile / | ||
+ | Include / | ||
+ | |||
+ | ProxyPreserveHost | ||
+ | ProxyRequests Off | ||
+ | |||
+ | # HSTS | ||
+ | < | ||
+ | Header always set Strict-Transport-Security " | ||
+ | </ | ||
+ | |||
+ | # proxy pour cetificat | ||
+ | DocumentRoot / | ||
+ | ProxyPass / | ||
+ | |||
+ | |||
+ | ProxyPass / https:// | ||
+ | ProxyPassReverse / https:// | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # For WebSockets | ||
+ | RewriteEngine on | ||
+ | RewriteCond %{HTTP: | ||
+ | RewriteCond %{HTTP: | ||
+ | RewriteRule /(.*) wss:// | ||
+ | |||
+ | RequestHeader set X-Forwarded-Proto “https” | ||
+ | RequestHeader set X-Forwarded-Port “443” | ||
+ | #SetEnv proxy-sendchunks 1 | ||
+ | |||
+ | <Proxy *> | ||
+ | Order deny,allow | ||
+ | Allow from all | ||
+ | </ | ||
+ | |||
+ | ErrorLog / | ||
+ | LogLevel error | ||
+ | CustomLog / | ||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | A noter le LogLevel à mettre sur debug à la place de error si debug voir [[https:// | ||
+ | ]] | ||
+ | **Ajouter l' | ||
+ | nano /etc/hosts | ||
+ | 10.0.3.243 ynh.futuretic.fr | ||
+ | |||
+ | **Il faut aussi donner des règles pour transférer les websockets**, | ||
+ | sudo a2enmod headers | ||
+ | sudo systemctl restart apache2 | ||
+ | | ||
+ | **Il est nécessaire d' | ||
+ | SSLProxyVerify none | ||
+ | SSLProxyCheckPeerCN off | ||
+ | SSLProxyCheckPeerName off | ||
+ | SSLProxyCheckPeerExpire off | ||
+ | | ||
+ | Pour débug : | ||
+ | coté hôte : tail -f / | ||
+ | coté ynh lxc : tail -f / | ||
+ | |||
+ | Et le debuggeur du navigateur | ||
+ | ==== Créer un nouveau certificat pour un sous domaine proxy vers yunohost ==== | ||
+ | nano / | ||
+ | cd / | ||
+ | a2ensite 000-ynh2ssl.futuretic.fr.conf | ||
+ | systemctl reload apache2 | ||
+ | certbot certonly --http-01-address 135.181.129.123 -d pass.futuretic.fr | ||
+ | a2dissite 000-ynh2ssl.futuretic.fr.conf | ||
+ | cp cpad.futuretic.fr.conf pass.futuretic.fr.conf | ||
+ | cp cpad.futuretic.fr-le-ssl.conf pass.futuretic.fr-le-ssl.conf | ||
+ | | ||
+ | Remplacer cpad par pass (dans nano ctrl \ ) | ||
+ | nano pass.futuretic.fr.conf | ||
+ | nano pass.futuretic.fr-le-ssl.conf | ||
+ | a2ensite pass.futuretic.fr-le-ssl.conf pass.futuretic.fr.conf | ||
+ | Ajouter à l'ip du container le sous domaine pass.futuretic.fr dans le fichier host | ||
+ | nano /etc/hosts | ||
+ | systemctl reload apache2 | ||
+ | |||
+ | |||
+ | ===== Installation de yunohost | ||
+ | **Entrer dans le container** | ||
+ | lxc-attach ynh | ||
+ | root@ynh:~# | ||
+ | **Installer les outils de base** | ||
+ | apt update | ||
+ | apt upgrade | ||
+ | apt install curl git htop locate netcat nano nload iotop mcrypt rsync sudo unzip | ||
+ | **Lancer l' | ||
+ | curl https:// | ||
+ | Suivre la procédure de post install en définissant le domaine et le password admin | ||
+ | |||
+ | **Modif de sécu pou faire marcher le tout** | ||
+ | nano / | ||
+ | <code php> | ||
+ | # Follows the Web Security Directives from the Mozilla Dev Lab and the Mozilla $ | ||
+ | # https:// | ||
+ | # https:// | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | more_set_headers " | ||
+ | more_set_headers " | ||
+ | more_set_headers " | ||
+ | more_set_headers " | ||
+ | </ | ||
+ | |||
+ | Ci-dessus 3 lignes commentées, | ||
+ | |||
+ | **Créer un premier utilisateur via le back office de yunohost** | ||
+ | |||
+ | ==== Installation de Cryptpad via Yunohost ==== | ||
+ | L' | ||
+ | |||
+ | Il faut installer Cryptpad sur un (sous).domaine dédié | ||
+ | ** | ||
+ | Pour tuner la config, ça se passe là :** | ||
+ | nano / | ||
+ | <code js> | ||
+ | * | ||
+ | | ||
+ | */ | ||
+ | // httpSafeOrigin: | ||
+ | |||
+ | // | ||
+ | |||
+ | ... | ||
+ | |||
+ | / | ||
+ | | ||
+ | */ | ||
+ | logToStdout: | ||
+ | |||
+ | |||
+ | /* Log levels | ||
+ | * silly, verbose, debug, feedback, info, warn, error | ||
+ | * This will affect both logging to the console and the disk. | ||
+ | */ | ||
+ | logLevel: ' | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | **Redémarrer le service** | ||
+ | systemctl restart cryptpad | ||
+ | systemctl status cryptpad | ||
+ | journalctl -u cryptpad | ||
+ | |||
+ | |||
+ | ==== Installation et utilisation de Borg Backup pour faire des sauvegardes entre 2 Yunohost ==== | ||
+ | * Documentation https:// | ||
+ | Coté serveur A à sauvegarder, | ||
+ | systemctl status borg.service | ||
+ | journalctl -feu borg.service | ||
+ | Configuration du port et + | ||
+ | nano / | ||
+ | |||
+ | ==== Export de tous les Pads depuis un etherpad vieillissant dans yunohost pour archivage au format markdown ==== | ||
+ | Créer un répertoire de backup | ||
+ | mkdir etherpadbackup | ||
+ | Faire une sauvegarde de la db | ||
+ | mysqldump -u etherpad_mypads -p etherpad_mypads > / | ||
+ | Lister tous les pads de l' | ||
+ | mysql -u etherpad_mypads -p etherpad_mypads -e ' | ||
+ | Faire un script bash qui va créer un export au format etherpad et mardown de tous ces pads et les mettre dans un répertoire respectif | ||
+ | <code lang=bash> | ||
+ | #!/bin/sh | ||
+ | |||
+ | # The base url to where etherpad is hosted | ||
+ | ETHERPAD_SERVER=" | ||
+ | |||
+ | while IFS= read -r line; do | ||
+ | printf ' | ||
+ | echo " | ||
+ | curl " | ||
+ | curl " | ||
+ | done < $1 | ||
+ | |||
+ | </ | ||
+ | Lancer le script en passant le nom de fichier contenant la liste des pads en argument : | ||
+ | sh export_etherpad.sh pad_names.txt | ||
+ | Compresser les dossiers et les transférer en scp | ||
+ | tar -czvf etherpadmonserveurbackupmd.tar.gz / | ||
+ | Les fichiers au format markdown gardent +/- leur formattage quand ouvert dans l' | ||
+ | |||
+ | ==== Installation de Opensondage dans Yunohost ==== | ||
+ | Via la mécanique habituelle, petite subtilité : dans l' | ||
+ | |||
+ | Sinon à la fin de la création du sondage, les utilisateurs non loggués ne voient pas la page qui résume les liens et accès à l' | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | ===== Migration de Yunohost 4 Debian 10 à Yunohost 11 et Debian 11 ===== | ||
+ | Ça marche à priori tout seul, [[https:// | ||
+ | |||
+ | Dans le container ynh, taper : | ||
+ | yunohost tools migrations migrate --debug | ||
+ | |||
+ | {{tag>bj yunohost infrastructure futuretic linux etherpad codimd opensondage}} | ||
+ | |
yunohost_un_container_lxc.txt · Dernière modification : 2023/02/19 23:09 de Benjamin Labomedia