Visualiser une révision

[Tuto/HowTo] Nextcloud - Health Check avec HaProxy

voxdemonix : révision n°2 (06 octobre 2018 12:38:38)

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 d(削除) 'éliminer l (削除ここまで)(追記) e tester "l'état de santé" d (追記ここまで)es machines (削除) down (削除ここまで)tout en consommant le moins de ressources possible.
Mise en place
=============
Ajoutez [le script suivant](https://gitlab.com/voxdemonix/divers-script/blob/master/nextcloud/HealthCheck.php) à la racine de votre installation de Nextcloud.
```
cd /var/www/html/nextcloud/
wget https://gitlab.com/voxdemonix/divers-script/raw/master/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 # deny access to status.php
 acl restricted_page path_beg,url_dec -i /status.php
 http-request deny if restricted_page
	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://www.0rion.netlib.re/forum4/viewtopic.php?f=107&t=821) (article d'origine)