ErrorLog ${APACHE_LOG_DIR}/proxy_error.log
CustomLog ${APACHE_LOG_DIR}/proxy_access.log combined

<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerName ubu2404serv
	ServerAdmin webmaster@localhost

#	DocumentRoot /var/www/html

	<Location /gestionnaire-lb>
		SetHandler balancer-manager
		Require ip 192.168.48
	</Location>
 
	# ATTENTION : la directive ci-dessous DOIT précéder la directive ProxyPass suivante
	ProxyPass /gestionnaire-lb !

	Header add Set-Cookie "ROUTE_LB=site.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
	# Uniquement pour constater :
	Header add X-LB-Backend %{BALANCER_WORKER_NAME}e  
	Header add X-LB-Name %{BALANCER_NAME}e  

	<Proxy balancer://equilibrage>
		# réglage par défaut - alternatives : bytraffic, busyness ou heartbeat :
	#	ProxySet lbmethod=byrequests

	#	BalancerMember http://noeud1
	#	BalancerMember http://noeud4

	#	BalancerMember http://noeud1 loadfactor=1
	#	BalancerMember http://noeud4 loadfactor=4

		# le report sur un serveur de secours n'est effectif QU'APRÈS un premier échec 
		# je n'ai constaté un "rétablissement" (sur le premier serveur) qu'au bout de 41 à 45 secondes (indépendamment de la valeur de retry)
	#	ProxySet failonstatus=404,500

	#	BalancerMember http://noeud1
		# le + ci-dessous est, a priori, facultatif / retry est par défaut fixé à 60 secondes
	#	BalancerMember http://noeud4 status=+H retry=20

		# la valeur de stickysession doit reprendre le nom du cookie défini plus haut :
		ProxySet stickysession=ROUTE_LB
		BalancerMember http://noeud1 route=noeud1
		BalancerMember http://noeud4 route=noeud4
	</Proxy>

	ProxyVia Full

	ProxyAddHeaders On

	# ProxyPreserveHost On	#  Off par défaut - laisse intact l'entete Host de la requete

	# FAIRE SUPER ATTENTION ! En l'absence du / terminal dans les deux directives suivantes, les requetes serveur ou serveur/ fonctionnent MAIS PAS serveur/chemin
	ProxyPass / balancer://equilibrage/
	ProxyPassReverse / balancer://equilibrage/

	LogLevel warn
	LogFormat "%h %v %l %u %t \"%r\" %>s %b %{COOKIE_LB}C %{BALANCER_SESSION_ROUTE}e %{BALANCER_WORKER_ROUTE}e %{BALANCER_ROUTE_CHANGED}e" equilibriste
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log equilibriste

#	Session On
#	SessionEnv On
#	SessionHeader X-Replace-Session
#	SessionCookieName session path=/;httponly;secure;
#
#	<Location />
#		Session On
#		SessionEnv On
#		SessionHeader X-Replace-Session
#		SessionCookieName session path=/;httponly;secure;
#	</Location>

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

#	ErrorLog ${APACHE_LOG_DIR}/error.log
#	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
