Visualiser une révision

[Tuto/HowTo] Nextcloud - Health Check avec HaProxy

voxdemonix : révision n°7 (15 novembre 2018 18:35:18)

Introduction
============
Pour des raisons d'efficacité et d'optimisation, il est déconseillé d'utiliser l'_index.php_ ou _status.php_ afin de faire les Health Check de HaProxy ou tout autre frontend.
Ici nous allons utiliser un script dédié dont le but est de tester "l'état de santé" des machines tout en consommant le moins de ressources possible.
Rappel : En cas de mise à jours Nextcloud râlent s'il détecte des fichiers qui ne sont pas d'origine. Lors d'une update pensez donc a déplacer le fichiers ailleurs puis a le ré-insérer une fois la mise à jours terminée.
Mise en place
=============
**Ajoutez [le script suivant](https://gitlab.com/voxdemonix/(削除) divers-script/blob/master (削除ここまで)(追記) cluster/blob/master/HealthCheck (追記ここまで)/nextcloud/HealthCheck.php) à la racine de votre installation de Nextcloud.**
```
cd /var/www/html/nextcloud/
wget https://gitlab.com/voxdemonix/(削除) divers-script/raw/master (削除ここまで)(追記) cluster/raw/master/HealthCheck (追記ここまで)/nextcloud/HealthCheck.php
```
**Accordez dessus les bonnes permissions.**
```
chown www-data:www-data ./HealthCheck.php
```
**Adaptez puis ajoutez dans votre fichier de configuration HaProxy ( _/etc/haproxy/haproxy.cfg_ ), les lignes suivantes à votre backend qui gère votre cloud.**
```
 http-check expect status 204
 option httpchk GET http://www.my_cloud.com/HealthCheck.php HTTP/1.0
```
**Exemple :**
```
backend nextcloud_cluster
 mode http
 balance leastconn
 http-request add-header X-Forwarded-Proto https if { ssl_fc }
 option forwardfor
 http-check expect status 204
 option httpchk GET http://www.my_cloud.com/HealthCheck.php HTTP/1.0
 cookie SERVERID insert indirect nocache
 default-server inter 10s fastinter 500 fall 2 rise 2
 # force https
 acl http ssl_fc,not
 http-request redirect scheme https if http
	server Machine1 Machine1:80 weight 1 check cookie Machine1
	server Machine2 Machine2:80 weight 1 check cookie Machine2
```
**Maintenant éditez vos fichiers de configuration vhost pour apache2**
```
nano /etc/apache2/sites-enabled/vhost-www.my-cloud.com.conf
```
**Ajoutez les lignes suivante en adaptant éventuellement le path vers votre fichier log.**
```
SetEnvIf Request_URI HealthCheck.php dontlog
CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog
```
Farm Link
=========
* [[Tuto/HowTo] Nextcloud - add Health Check script for Load Balancer](https://wiki.0rion.netlib.re/doku.php?id=tuto_howto_nextcloud_health_check_avec_haproxy) (article d'origine)