Architecture Zabbix 1.8.11 de deux serveurs sous Ubuntu 12.04

 

Dans un environnement cloud amazon comment configurer un zabbix server avec le frontend php et un serveur mysql 5.5 avec le partitionnement des tables sur une ubuntu 12.04 afin d’avoir une architecture scalable et taillée pour de très forte charge. En effet les problèmes de performance de Zabbix sont liés à la base de données. Cela devient  visible seulement quand vous avez des milliers d’items. Cela conduit à devoir gérer des tables énormes et il  deviens impossible de faire le ménage dans l’historique (Housekeeper) ou des sauvegarde, d’ou le partitionnement de table en solution.

 

A Lire avant tout :

Cas Iscool Entertainement
Optimisation partitioning-tables
Procédures Mysql stockée pour tables mensuelles
Tips Mysql pour zabbix
Architecture Zabbix distribuée et scalable

 

Notice

Ceci n’est que le copier coller de notes de travail et en aucun cas une procédure à suivre au pied de la lettre en copiant collant.

 

Security group

Créer un security group monitor et les règles de sécurité.

ec2-add-group --region eu-west-1 Monitor l -d "Monitor"
ec2-authorize Monitor -P tcp -p 22 -s 0.0.0.0/0
ec2-authorize Monitor -P tcp -p 3306 -u 727387230542 -o "Monitor"
ec2-authorize Monitor -P tcp -p 10050 -u 727387230542 -o "Monitor"
ec2-authorize Monitor -P udp -p 10050 -u 727387230542 -o "Monitor"
ec2-authorize Monitor -P tcp -p 80 -u 727387230542 -o "Monitor"

Verifier le résultat de la configuration du security group.

ec2-describe-group Monitor
GROUP   sg-907282e6     727387230542    Monitor Monitor
PERMISSION      727387230542    Monitor ALLOWS  tcp     22      22      FROM    CIDR    0.0.0.0/0       ingress
PERMISSION      727387230542    Monitor ALLOWS  tcp     3306    3306    FROM    USER    727387230542    NAME Monitor    ID sg-907282e6  ingress
PERMISSION      727387230542    Monitor ALLOWS  tcp     10050   10050   FROM    USER    727387230542    NAME Monitor    ID sg-907282e6  ingress
PERMISSION      727387230542    Monitor ALLOWS  udp     10050   10050   FROM    USER    727387230542    NAME Monitor    ID sg-907282e6  ingress
PERMISSION      727387230542    Monitor ALLOWS  tcp     80      80      FROM    CIDR    0.0.0.0/0       ingress

 

Mysql

Lancer une instance m1.large avec un maximum de disque éphémère.

ec2-run-instances ami-094c666d -k infra-live -g Monitor -b "sdb=ephemeral0" -b "sdc=ephemeral1" -b "sdd=ephemeral2" -b "sde=ephemeral3" -t m1.large -z eu-west-1b -d hostname=monitorweb1

Vérifier le résultat du lancement d’instance

ec2-describe-instances i-abda3ce2
RESERVATION     r-a2da48eb      727387230542    Monitor
INSTANCE        i-abda3ce2      ami-094c666d    ec2-176-34-201-131.eu-west-1.compute.amazonaws.com      ip-10-51-45-30.eu-west-1.compute.internal       running infra-live      0               m1.large 2012-04-16T15:18:19+0000        eu-west-1b      aki-62695816                    monitoring-disabled     176.34.201.130  10.51.45.30                     ebs                             paravirtual      xen             sg-907282e6     default
BLOCKDEVICE     /dev/sda1       vol-be4aeed6    2012-04-16T15:18:34.000Z        true
TAG     instance        i-abda3ce2      Name    monitor-sql1

Ajouter un tag name à cette instance

ec2-create-tags i-abda3ce2 --tag Name=monitorweb1

Logger vous sur l’instance et installer Mysql 5.5 qui est disponible dans les dépôts ubuntu 12.04 . Bien noté l’ID et le mots de passe du super-administrateur mysql

apt-get install mysq-server maatkit

Modifier l’installation de Mysql

/etc/init.d/mysql stop
cd /mnt/
rm -r lost+found/
mkdir mysql-bin
chown mysql.mysql mysql-bin/

Effacer la base mysql par defaut

cd /var/lib/mysql
rm -r *

Reconfigurer */etc/fstab* pour avoir /var/lib/mysql sur le disque non utilisé */dev/xvdc*

LABEL=cloudimg-rootfs	/	 ext4	defaults	0 0
/dev/xvdb	/mnt	auto	rw,suid,dev,exec,auto,nouser,async,noatime,nodiratime	0	2
/dev/xvdc	/var/lib/mysql	auto	rw,suid,dev,exec,auto,nouser,async,noatime,nodiratime	0	2

Monter le filesytem

mount -a

Réinstaller la DB par défaut de Mysql

cd /var/lib/mysql/
mysql_install_db

Configurer mysql avec deux fichiers:
Le premier */etc/mysql/conf.d/zabbix.cnf* avec la configuration de Mysql standalone server spéciale m1.large

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
user            = mysql
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr

skip-external-locking

# network binding
bind-address = 0.0.0.0
skip-name-resolve

# charsets
# Deprecated default-character-set=utf8
# Deprecated default-collation=utf8
collation_server=utf8_general_ci
character_set_server=utf8
skip-character-set-client-handshake

# paths
datadir                         = /var/lib/mysql
tmpdir                          = /tmp

# network
connect_timeout                 = 5
interactive_timeout             = 30
max_allowed_packet              = 1M
max_connect_errors              = 4096
max_connections                 = 1200
wait_timeout                    = 30

# limits
max_heap_table_size             =
table_open_cache                = 8192
thread_cache_size               = 512

#$processorcount * 2
thread_concurrency              = 4
tmp_table_size                  =

# logs
log_error                       = /var/log/mysql/mysql-error.log
log_queries_not_using_indexes   = 1
log_warnings                    = 1
long_query_time                 = 1
slow_query_log                  = 1
slow_query_log_file             = /var/log/mysql/mysql-slow.log

# query cache
query_cache_limit               = 1M
query_cache_size                = 128M
query_cache_type                = 1

# buffers
key_buffer_size                 = 32M
read_buffer_size                =
sort_buffer_size                = 1M

# other stuff
event_scheduler                 = 1

# InnoDB storage engine config options
default-storage-engine  = InnoDB
innodb_additional_mem_pool_size = 128M
innodb_autoextend_increment     = 64
innodb_buffer_pool_size         = 3000M
innodb_data_home_dir            = /var/lib/mysql
innodb_data_file_path           = ibdata1:128M:autoextend
innodb_file_per_table           = 1
innodb_flush_log_at_trx_commit  = 2
innodb_flush_method             = O_DIRECT
innodb_io_capacity              = 300
innodb_log_buffer_size          =
innodb_log_file_size            = 128M
innodb_log_files_in_group       =
innodb_mirrored_log_groups      = 1
innodb_max_dirty_pages_pct      = 45
innodb_status_file              = 0
innodb_support_xa               = 1
innodb_thread_concurrency       = 8

# experimental
#innodb_stats_update_need_lock  =

Le second */etc/mysql/conf.d/zabbix.local.cnf* avec la configuration de Mysql pour sa réplication Master/Slave

##################################################################
# Ce fichier contient les parametres specifiques a la replication
[mysqld]

# conf commune a tous les slaves
log_bin=/mnt/mysql-bin/mysql-bin.log
expire_logs_days=10
max_binlog_size=100M
sync_binlog=0
log-slave-updates
replicate-same-server-id=0
auto_increment_increment=2
slave-skip-errors=1053
binlog_format=MIXED

# fix pb relay-log dependant du hostname
relay-log=mysqld-relay-bin
relay-log-index=mysqld-relay-bin.index

# Conf specifique a ce slave en particulier

# chaque replicat doit avoir un server-id unique (1,2,3,4...)
server-id=1
# role de l'offset: un replicat ne cree que des ids pairs, et l'autre que des ids impairs
# ceci afin d'eviter au maximum les conflits
# valeurs possibles: 2 (ids pairs)  1 (ids impairs)
auto_increment_offset=1
# tout replicat autre que le master actif doit etre en read-only
# autrement dit, seul le master actif peut traiter les ecritures
# read-only

Installer le paquet mysql de zabbix

zabbix-server-mysql

Créé une AMI par sécurité

ec2-create-image -n Mysql55-U1204-m1large -d Mysql55-U1204--m1large-v1 i-abda3ce2

 

Zabbix Server et FrontEnd php

Lancer une instance c1.medium

ec2-run-instances  ami-094c666d -k infra-live -g Monitor -b "sdb=ephemeral0" -b "sdc=ephemeral1" -b "sdd=ephemeral2" -b "sde=ephemeral3" -t c1.medium -z eu-west-1b -d hostname=monitorweb1

RESERVATION     r-e06df1a9      727387230542    Monitor
INSTANCE        i-eb00e3a3      ami-094c666d                    pending infra-live      0               c1.medium       2012-04-18T13:13:06+0000        eu-west-1b      aki-62695816            monitoring-disabled                                      ebs                                     paravirtual     xen             sg-907282e6     default

Donner un tag name à cette instance

ec2-create-tags i-eb00e3a3 --tag Name=monitor-web1

Installer les paquets suivant

apt-get instal libapache2-mod-php5 php-apc php5 php5-cli php5-common php5-gd php5-mysql zabbix-frontend-php zabbix-server-mysql  bsd-mailx

Puis Deinstaller les paquets *mysql-server* qu’un dépendance à forcer à l’installation.

apt-get remove --purge mysql-server*

Configurer Apache avec les modules suivent. Les autres ne sont pas nécéssaire.

auth_basic.load
authz_default.load
authz_host.load
deflate.conf
deflate.load
php5.conf
php5.load
status.conf
status.load

Modifier le lancement du module deflate de apache
Pour une compression légère sur tout ce qui est texte ceci sur l’exemple du fichier */etc/apache2/mods-enabled/deflate.conf* suivant

          AddOutputFilterByType DEFLATE text/html text/plain text/xml
          AddOutputFilterByType DEFLATE text/xml
          AddOutputFilterByType DEFLATE text/css
          AddOutputFilterByType DEFLATE text/javascript
          AddOutputFilterByType DEFLATE text/html
          AddOutputFilterByType DEFLATE text/plain
          AddOutputFilterByType DEFLATE application/xml
          AddOutputFilterByType DEFLATE application/xhtml+xml
          AddOutputFilterByType DEFLATE application/rss+xml
          AddOutputFilterByType DEFLATE application/javascript
          AddOutputFilterByType DEFLATE application/x-javascript

          DeflateCompressionLevel 3

Configurer APC sur le modèle du fichier */etc/php5/conf.d/apc.ini* suivant

extension=apc.so
apc.enabled="1"
apc.shm_size="64M"
apc.num_files_hint="100"
apc.user_entries_hint="0"
apc.ttl="0"
apc.gc_ttl="3601"
apc.stat="1"
apc.slam_defense="0"
apc.write_lock="1"

Configurer frontend php pour utiliser le serveur mysql précédement créé sur le modèle du fichier */etc/zabbix/dbconfig.php* suivant


Configurer zabbix serveur pour utiliser le serveur mysql précédement créé sur le modèle du fichier */etc/zabbix/zabbix_server.conf* suivant

LogFile=/var/log/zabbix-server/zabbix_server.log
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=monitor-sql1.DOMAINENAME.COM
DBName=zabbix
DBUser=zabbix
DBPassword=password
AlertScriptsPath=/etc/zabbix/alert.d/
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6

 

Configurer la base de donnée avec le partitionnement des tables

Configurer les droits et password de root mysql même si c’est déjà fait

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Créer et configurer les droits et password de l’utilisation zabbix

GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Modification de la DB zabbix

ALTER TABLE acknowledges DROP PRIMARY KEY, ADD KEY acknowledgedid (acknowledgeid);
ALTER TABLE alerts DROP PRIMARY KEY, ADD KEY alertid (alertid);
ALTER TABLE auditlog DROP PRIMARY KEY, ADD KEY auditid (auditid);
ALTER TABLE events DROP PRIMARY KEY, ADD KEY eventid (eventid);
ALTER TABLE service_alarms DROP PRIMARY KEY, ADD KEY servicealarmid (servicealarmid);
ALTER TABLE history_log DROP PRIMARY KEY, ADD PRIMARY KEY (itemid,id,clock);
ALTER TABLE history_log DROP KEY history_log_2;
ALTER TABLE history_text DROP PRIMARY KEY, ADD PRIMARY KEY (itemid,id,clock);
ALTER TABLE history_text DROP KEY history_text_2;

Partitionner les tables journalières de la DB zabbix

ALTER TABLE events PARTITION BY RANGE( clock ) (
PARTITION p201204 VALUES LESS THAN (UNIX_TIMESTAMP("2012-05-01 00:00:00")));
ALTER TABLE acknowledges PARTITION BY RANGE( clock ) (
PARTITION p201204 VALUES LESS THAN (UNIX_TIMESTAMP("2012-05-01 00:00:00")));
ALTER TABLE alerts PARTITION BY RANGE( clock ) (
PARTITION p201204 VALUES LESS THAN (UNIX_TIMESTAMP("2012-05-01 00:00:00")));
ALTER TABLE auditlog PARTITION BY RANGE( clock ) (
PARTITION p201204 VALUES LESS THAN (UNIX_TIMESTAMP("2012-05-01 00:00:00")));
ALTER TABLE service_alarms PARTITION BY RANGE( clock ) (
PARTITION p201204 VALUES LESS THAN (UNIX_TIMESTAMP("2012-05-01 00:00:00")));
ALTER TABLE trends PARTITION BY RANGE( clock ) (
PARTITION p201204 VALUES LESS THAN (UNIX_TIMESTAMP("2012-05-01 00:00:00")));
ALTER TABLE trends_uint PARTITION BY RANGE( clock ) (
PARTITION p201204 VALUES LESS THAN (UNIX_TIMESTAMP("2012-05-01 00:00:00")));

Partitionner les tables mensuelles de la DB zabbix

ALTER TABLE history_uint PARTITION BY RANGE( clock ) (
PARTITION p20110419 VALUES LESS THAN (UNIX_TIMESTAMP("2011-04-20 00:00:00")));
ALTER TABLE history PARTITION BY RANGE( clock ) (
PARTITION p20110419 VALUES LESS THAN (UNIX_TIMESTAMP("2011-04-20 00:00:00")));
ALTER TABLE history_log PARTITION BY RANGE( clock ) (
PARTITION p20110419 VALUES LESS THAN (UNIX_TIMESTAMP("2011-04-20 00:00:00")));
ALTER TABLE history_str PARTITION BY RANGE( clock ) (
PARTITION p20110419 VALUES LESS THAN (UNIX_TIMESTAMP("2011-04-20 00:00:00")));
ALTER TABLE history_str PARTITION BY RANGE( clock ) (
PARTITION p20110419 VALUES LESS THAN (UNIX_TIMESTAMP("2011-04-20 00:00:00")));
ALTER TABLE history_text PARTITION BY RANGE( clock ) (
PARTITION p20110419 VALUES LESS THAN (UNIX_TIMESTAMP("2011-04-20 00:00:00")));

Enregistrer les procedures stockées
Procédure pour tables quotidiennes

/**************************************************************
  MySQL Auto Partitioning Procedure for Zabbix 1.8

http://zabbixzone.com/zabbix/partitioning-tables/

  Author:  Ricardo Santos (rsantos at gmail.com)
  Version: 20110518
**************************************************************/
DELIMITER //
DROP PROCEDURE IF EXISTS `zabbix`.`create_zabbix_partitions` //
CREATE PROCEDURE `zabbix`.`create_zabbix_partitions` ()
BEGIN
	CALL zabbix.create_next_partitions("zabbix","history");
	CALL zabbix.create_next_partitions("zabbix","history_log");
	CALL zabbix.create_next_partitions("zabbix","history_str");
	CALL zabbix.create_next_partitions("zabbix","history_text");
	CALL zabbix.create_next_partitions("zabbix","history_uint");
	CALL zabbix.drop_old_partitions("zabbix","history");
	CALL zabbix.drop_old_partitions("zabbix","history_log");
	CALL zabbix.drop_old_partitions("zabbix","history_str");
	CALL zabbix.drop_old_partitions("zabbix","history_text");
	CALL zabbix.drop_old_partitions("zabbix","history_uint");
END //
DROP PROCEDURE IF EXISTS `zabbix`.`create_next_partitions` //
CREATE PROCEDURE `zabbix`.`create_next_partitions` (SCHEMANAME varchar(64), TABLENAME varchar(64))
BEGIN
	DECLARE NEXTCLOCK timestamp;
	DECLARE PARTITIONNAME varchar(16);
	DECLARE CLOCK int;
	SET @totaldays = 7;
	SET @i = 1;
	createloop: LOOP
		SET NEXTCLOCK = DATE_ADD(NOW(),INTERVAL @i DAY);
		SET PARTITIONNAME = DATE_FORMAT( NEXTCLOCK, 'p%Y%m%d' );
		SET CLOCK = UNIX_TIMESTAMP(DATE_FORMAT(DATE_ADD( NEXTCLOCK ,INTERVAL 1 DAY),'%Y-%m-%d 00:00:00'));
		CALL zabbix.create_partition( SCHEMANAME, TABLENAME, PARTITIONNAME, CLOCK );
		SET @i=@i+1;
		IF @i > @totaldays THEN
			LEAVE createloop;
		END IF;
	END LOOP;
END //
DROP PROCEDURE IF EXISTS `zabbix`.`drop_old_partitions` //
CREATE PROCEDURE `zabbix`.`drop_old_partitions` (SCHEMANAME varchar(64), TABLENAME varchar(64))
BEGIN
	DECLARE OLDCLOCK timestamp;
	DECLARE PARTITIONNAME varchar(16);
	DECLARE CLOCK int;
	SET @mindays = 3;
	SET @maxdays = @mindays+4;
	SET @i = @maxdays;
	droploop: LOOP
		SET OLDCLOCK = DATE_SUB(NOW(),INTERVAL @i DAY);
		SET PARTITIONNAME = DATE_FORMAT( OLDCLOCK, 'p%Y%m%d' );
		CALL zabbix.drop_partition( SCHEMANAME, TABLENAME, PARTITIONNAME );
		SET @i=@i-1;
		IF @i

Procédure pour tables mensuelles

DELIMITER //
DROP PROCEDURE IF EXISTS `zabbix`.`create_zabbix_monthly_partitions` //
CREATE PROCEDURE `zabbix`.`create_zabbix_monthly_partitions` ()
BEGIN
CALL zabbix.create_next_monthly_partitions("zabbix","acknowledges");
CALL zabbix.create_next_monthly_partitions("zabbix","alerts");
CALL zabbix.create_next_monthly_partitions("zabbix","auditlog");
CALL zabbix.create_next_monthly_partitions("zabbix","events");
CALL zabbix.create_next_monthly_partitions("zabbix","service_alarms");
CALL zabbix.create_next_monthly_partitions("zabbix","trends");
CALL zabbix.create_next_monthly_partitions("zabbix","trends_uint");
CALL zabbix.drop_old_monthly_partitions("zabbix","acknowledges");
CALL zabbix.drop_old_monthly_partitions("zabbix","alerts");
CALL zabbix.drop_old_monthly_partitions("zabbix","auditlog");
CALL zabbix.drop_old_monthly_partitions("zabbix","events");
CALL zabbix.drop_old_monthly_partitions("zabbix","service_alarms");
CALL zabbix.drop_old_monthly_partitions("zabbix","trends");
CALL zabbix.drop_old_monthly_partitions("zabbix","trends_uint");
END //
DROP PROCEDURE IF EXISTS `zabbix`.`create_next_monthly_partitions` //
CREATE PROCEDURE `zabbix`.`create_next_monthly_partitions` (SCHEMANAME varchar(64), TABLENAME varchar(64))
BEGIN
DECLARE NEXTCLOCK timestamp;
DECLARE PARTITIONNAME varchar(16);
DECLARE CLOCK int;
SET @totalmonths = 3;
SET @i = 1;
createloop: LOOP
SET NEXTCLOCK = DATE_ADD(NOW(),INTERVAL @i MONTH);
SET PARTITIONNAME = DATE_FORMAT( NEXTCLOCK, 'p%Y%m' );
SET CLOCK = UNIX_TIMESTAMP(DATE_FORMAT(DATE_ADD( NEXTCLOCK ,INTERVAL 1 MONTH),'%Y-%m-01 00:00:00'));
CALL zabbix.create_partition( SCHEMANAME, TABLENAME, PARTITIONNAME, CLOCK );
SET @i=@i+1;
IF @i > @totalmonths THEN
LEAVE createloop;
END IF;
END LOOP;
END //
DROP PROCEDURE IF EXISTS `zabbix`.`drop_old_monthly_partitions` //
CREATE PROCEDURE `zabbix`.`drop_old_monthly_partitions` (SCHEMANAME varchar(64), TABLENAME varchar(64))
BEGIN
DECLARE OLDCLOCK timestamp;
DECLARE PARTITIONNAME varchar(16);
DECLARE CLOCK int;
SET @minmonths = 12;
SET @maxmonths = @minmonths+3;
SET @i = @maxmonths;
droploop: LOOP
SET OLDCLOCK = DATE_SUB(NOW(),INTERVAL @i MONTH);
SET PARTITIONNAME = DATE_FORMAT( OLDCLOCK, 'p%Y%m' );
CALL zabbix.drop_partition( SCHEMANAME, TABLENAME, PARTITIONNAME );
SET @i=@i-1;
IF @i

Vérifier le bon enregistrements des procedures stockées

select name from mysql.proc;
+----------------------------------+
| name                             |
+----------------------------------+
| create_next_monthly_partitions   |
| create_next_partitions           |
| create_partition                 |
| create_zabbix_monthly_partitions |
| create_zabbix_partitions         |
| drop_old_monthly_partitions      |
| drop_old_partitions              |
| drop_partition                   |
+----------------------------------+

Créé les cron journalié et mensuel de changement de table
Sur monitor-web1

mkdir -p /etc/zabbix/cron.d

Créer le fichier */etc/zabbix/cron.d/daily-housekeeping.sh*

#!/bin/bash

MAILTO=karles@mimesis-republic.com
tmpfile=/tmp/daily-housekeeping$$

date >$tmpfile
/usr/bin/mysql --skip-column-names -B -h localhost -u zabbix -pzabbix zabbix -e "CALL create_zabbix_partitions();" >>$tmpfile 2>&1
/usr/bin/mail -s "[Zabbix] Daily MySql Partition Housekeepingg" $MAILTO

Créer le fichier */etc/cron.daily/zabbix-daily-housekeeping*

#!/bin/bash
/etc/zabbix/cron.d/daily-housekeeping.sh

Créer le fichier */etc/zabbix/cron.d/monthly-housekeeping.sh*

#!/bin/bash

MAILTO=karles@mimesis-republic.com
tmpfile=/tmp/monthly-housekeeping$$

date >$tmpfile
/usr/bin/mysql --skip-column-names -B -h monitor-sql1.DOMAINENAME.COM -u zabbix -ppass zabbix -e "CALL create_zabbix_monthly_partitions();" >>$tmpfile 2>&1
/usr//bin/mail -s "[Zabbix] Monthly MySql Partition Housekeeping" $MAILTO

Créer le fichier */etc/cron.monthly/zabbix-monthly-housekeeping*

#!/bin/bash
/etc/zabbix/cron.d/monthly-housekeeping.sh

Lancer les deux cron manuellement pour finir l’installation.

 

Pootle est un outil de management de traduction en ligne souvent utilisé pour internationalisé une application.

Le paquet Pootle

L’installation facile avec apt.

apt-get update apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> pootle

Modifier /etc/default avec

 POOTLE_ENABLE=Yes

Modifier dans le fichier /etc/pootle/pootle.prefs les lignes 63 a 64 sur le modèle suivant :

<span style="color: #000000;">63</span>     fromaddress = <span style="color: #ff0000;">&quot;pootle@domaine.com&quot;</span>  <span style="color: #000000;">64</span>     smtpserver = <span style="color: #ff0000;">&quot;localhost&quot;</span>  <span style="color: #000000;">65</span>     supportaddress = <span style="color: #ff0000;">&quot;pootle@domaine.com&quot;</span>

Relancer pootle via la commande :

 /etc/init.d/pootle restart

Vérifier la disponibilité en local via la commande :

 curl -I http://localhost:8080

Installer un service de mail (envois de code d’inscription) si nécessaire via la commande :

 apt-get install postfix

Install Apache2 en proxy de Pootle

Ajouter module proxy via la commande :

 a2enmod proxy proxy_http

Pour éviter les accès interdit (error 403) configurer /etc/apache2/mods-available/proxy.conf avec la directive :

 Allow from all.

Ajouter un vhost apache2 pour pootle

&lt;VirtualHost *:<span style="color: #ff0000;">80</span>&gt;  <span style="color: #00007f;">ServerName</span> pootle.cafe.com  <span style="color: #00007f;">ProxyPass</span> /images !  <span style="color: #00007f;">ProxyPass</span> /js !  <span style="color: #00007f;">ProxyPass</span> /pootle.css !  <span style="color: #00007f;">ProxyPass</span> /favicon.ico !  <span style="color: #00007f;">ProxyPass</span> / http://localhost:<span style="color: #ff0000;">8080</span>/  <span style="color: #00007f;">ProxyPassReverse</span> / http://localhost:<span style="color: #ff0000;">8080</span>/ &nbsp;  &lt;Directory proxy:http://localhost:<span style="color: #ff0000;">8080</span>/*&gt;      <span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>      <span style="color: #00007f;">Allow</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>  &lt;/Directory&gt; &nbsp;  <span style="color: #adadad; font-style: italic;"># Possible values include: debug, info, notice, warn, error, crit,</span>  <span style="color: #adadad; font-style: italic;"># alert, emerg.</span>  <span style="color: #00007f;">LogLevel</span> warn  <span style="color: #00007f;">ErrorLog</span> /var/log/apache2/pootle-error_log  <span style="color: #00007f;">CustomLog</span> /var/log/apache2/pootle-access_log common &nbsp;  <span style="color: #adadad; font-style: italic;"># Fallback for static html content</span>  <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/usr/share/pootle/html&quot;</span> &nbsp;  &lt;Directory <span style="color: #7f007f;">&quot;/usr/share/pootle/html&quot;</span>&gt;    <span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>    <span style="color: #00007f;">Allow</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>  &lt;/Directory&gt; &nbsp; &lt;/VirtualHost&gt;

Relancer apache via la commande :

 /etc/init.d/apache2 restart

Tester que le vhost et le ServerName configurer répond via la commande :

 curl -H "Host: pootle.cafe.com" http://localhost/

Ouvrir le compte admin dans Pootle

Lire /usr/share/doc/pootle/README.Debian sur le serveur Pootle

Si le ServerName dans le Vhost Pootle ne correspond pas à une entré DNS modifier votre fichier /etc/hosts en conséquence

Ouvir un compte avec le login admin en vous connectant sur le serveur pootle : http://servername

Valider l’ouverture de compte avec le Registration code reçu pas email

Modifier le fichier /etc/pootle/users.prefs afin d’ajouter les droits d’administration au compte créé. Pour cela ajouter la ligne rights.siteadmin = True comme dans l’exemple suivant en tenant compte de l’indentation. admin:

activated = <span style="color: #000000;">1</span>   activationcode = <span style="color: #ff0000;">'e0e0eaa3840daf3833c16774aec95aa7'</span>   email = u<span style="color: #ff0000;">'karles@domaine.com'</span>   name = u<span style="color: #ff0000;">'Administrator'</span>   passwdhash = <span style="color: #ff0000;">'20b47a2e5debe0df2954b9307a7be7691'</span>   uilanguage = u<span style="color: #ff0000;">'fr'</span>   rights.siteadmin = True

Relancer pootle via la commande :

 /etc/init.d/pootle restart
 

Pour compléter mon billet sur l’utilisation du mod_deflate pour un hébergement apache 2 de Dotclear2 et celui sur Optimisation d’un hébergement eZ Publish 4 pour l’utilisation des caches web ou je parle du mod_gzip de apache 1.3 je vous invite à consulter le billet use mod_deflate to compress web content delivered by apache sur g-loaded.eu. Cette recommandation est valable quelque soit le CMS ou application web du moment que votre solution de web hosting repose sur apache 2. Vous en apprendrez plus sur les points suivants :

Configurer le niveau de compression de mod_deflate

L’algorithme deflate est assez rapide et il est possible de modifier le niveau de compression. Le mettre au maximum ne pose pas de problème si vous vous contentez de compresser du texte (css, Js, xml etc) [1]

DeflateCompressionLevel <span style="color: #ff0000;">9</span>

Surveiller la compression via les logs

Vous pouvez avoir une trace log de la compression effectué par le mod_deflate de votre serveur apache 2.[2]

Le directive suivant définissent quelque variable :

  • instream : La taille en Bytes (Octet) en entré de DEFLATE.
  • outstream : La taille en Bytes (Octet) en sortie de DEFLATE.
  • ratio : Le ratio de compression, (Sortie/Entré)x100
DeflateFilterNote Input instream DeflateFilterNote Output outstream DeflateFilterNote Ratio ratio

Les variables définie vous pouvez ajouter une Format de log à votre vhost:

<span style="color: #00007f;">LogFormat</span> <span style="color: #7f007f;">'&quot;%r&quot; %{outstream}n/%{instream}n (%{ratio}n%%)'</span> deflatelog

N’oubliez par d’utiliser de format de log en l’écrivant dans un fichier de log.

<span style="color: #00007f;">CustomLog</span> /path/to/vhost/logs/deflate_log deflatelog

Vous obtenez un log pour deflate qui ce présente comme cela. Pratique pour étudier l’utilité de la compression de donner en fonction du type de fichier dans votre architecture d’hébergement ou des efforts de Minification, toujours important en web hosting.

<span style="color: #7f007f;">&quot;GET /dotclear/themes/default/js/jquery.cookie.js HTTP/1.1&quot;</span> <span style="color: #ff0000;">451</span>/<span style="color: #ff0000;">994</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">45</span>%<span style="color: #66cc66;">&#41;</span>

Notes

[1] Attention comprimer au maximum des fichiers trop gros ou déjà compressé comme les images est contre productif !!

[2] Attention écrire des logs sur le disque ralenti apache !!

 

Introduction au cache web

Documentation préalable

Si la gestion de cache web est pour vous une notion vague je vous invite à lire cette excellente documentation de Mark Nottingham en français nommée tutoriel de la mise en cache pour les auteurs Web et les webmestres. Vous y apprendrez tout sur les caches de navigateurs les caches de serveurs mandataires nommé proxy et reverses proxy ainsi que tout sur la configuration des en tête ou header du protocole HTTP nécessaire tel quel documenté dans la rfc 2616 section Caching in HTTP

La chaîne des caches.

Les caches web forme sont présent sur tout la chaîne de distribution entre vote site web et l’internaute. Cette chaîne peux être complexe ou très simple mais vous n’en maitrisez pas la structure. Imaginons le cas d’une chaîne complexe, quel sont les chainons ?

  1. Votre serveur web apache
  2. Un reverse proxy en amont de votre serveur sur la même architecture
  3. Un proxy chez le FAI dont dépendant la connexion de l’internaute
  4. Un second proxy en entré du réseau Lan de l’internaute (typique d’un réseau d’entreprise, école, université etc..)
  5. Le cache navigateur du logiciel client utilisé pour l’internaute pour consulté votre site.
  6. Et enfin l’internaute.

Entre votre serveur apache et l’internaute nous avons ici 4 étapes intermédiaires qui sont autant de cache sur la chaîne de distribution. Savoir tirer partie de ces caches est important pour économiser les ressources de votre hébergement et produire un site à l’affichage rapide et sans erreur (qualité indispensable au succès).

L’enjeux est important :

  • Les économies réalisables sont immenses. Dans l’exemple 4 services de cache peuvent répondre à l’internaute avant que votre propre serveur soient consulté.
  • Les dangers sont immenses. Dans l’exemple 4 services de cache peuvent répondre à l’internaute, avant votre propre serveur, une information obsolète que vous n’avez pas maitrisé.

 

Les acteurs: développeur et administrateur système LAMP[1]

La gestion des caches web pour une site eZ publish est le sujet d’exemple de la collaboration nécessaire entre les développeur ou responsable d’application et les responsable d’hébergement ou administrateur système.

Dans le cas ou vous ne maitrisez pas votre hébergement directement, quelque soit la raison, il est nécessaire de vous attacher les compétences de l’administrateur système en charge de votre serveur web.

 

Tâche à la charge du developpeur ou responsable d’application eZ Publish

Le développeur, ayant la haute main sur le code de son application, ce doit pour une parfaite configuration de la chaine des caches web de configurer son instance de eZ Publish pour cela. A cette fin il s’attachera à comprendre les paramètres de configuration de la section HTTPHeaderSettings du fichier site.ini[2]

Header HTTP par defaut de eZ publish

Voici tel que ce présente cette section HTTPHeaderSettings par défaut sans modification après une installation de eZ publish 4.2. Cette configuration par défaut désactive toute possibilité de cache web.

<span style="color: #66cc66;">[</span>HTTPHeaderSettings<span style="color: #66cc66;">]</span> <span style="color: #808080; font-style: italic;"># Enable/disable custom HTTP header data.</span> CustomHeader<span style="color: #66cc66;">=</span>disabled   <span style="color: #808080; font-style: italic;"># Only apply custom headers for anonymous users</span> OnlyForAnonymous<span style="color: #66cc66;">=</span>disabled   <span style="color: #808080; font-style: italic;"># Header list. Contains all HTTP which should override standard ones.</span> HeaderList<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> HeaderList<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span>Cache<span style="color: #66cc66;">-</span>Control HeaderList<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span>Pragma HeaderList<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span>Expires   <span style="color: #808080; font-style: italic;"># Default Cache-Control header</span> <span style="color: #808080; font-style: italic;"># HTTP Headers are specified using the following format :</span> <span style="color: #808080; font-style: italic;"># &lt;HTTP header&gt;[&lt;eZ Publish path|module{/view}&gt;]=&lt;value&gt;{;&lt;depth&gt;{;&lt;level&gt;}}</span> <span style="color: #808080; font-style: italic;">#</span> <span style="color: #808080; font-style: italic;"># Example :</span> <span style="color: #808080; font-style: italic;"># # Set Pragma HTTP header to no-cache for whole site, except /news, and 2 levels below news.</span> <span style="color: #808080; font-style: italic;"># Pragma[]</span> <span style="color: #808080; font-style: italic;"># Pragma[/]=no-cache;2</span> <span style="color: #808080; font-style: italic;"># Pragma[/news]=;2;0</span>   <span style="color: #808080; font-style: italic;"># Cache-Control values are set directly</span> Cache<span style="color: #66cc66;">-</span>Control<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> Cache<span style="color: #66cc66;">-</span>Control<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span>no<span style="color: #66cc66;">-</span>cache<span style="color: #66cc66;">,</span> must<span style="color: #66cc66;">-</span>revalidate   <span style="color: #808080; font-style: italic;"># Pragma values are set directly</span> Pragma<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> Pragma<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span>no<span style="color: #66cc66;">-</span>cache   <span style="color: #808080; font-style: italic;"># Expires specifies time offset compared to current time</span> <span style="color: #808080; font-style: italic;"># Default expired 2 hours ago ( no caching )</span> Expires<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> Expires<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">-7200</span>

Header HTTP de eZ publish pour Voici.fr

Sur Voici.fr nous avons fait les choix suivants:

  • Un cache à 5 minutes pour la home page afin d’être réactif tout en utilisant le cache web. Cette période courte offre la possibilité d’avoir une actualisation de site fréquente entre deux visites pour l’internaute tout en lissant le nombre de requêtes à nos serveur durant une même visite.
  • Pour les têtes de rubriques, flux rss et autre sitemap nous avons porté le temps de cache à 15 minutes
  • Pour le compte utilisateur et les fonctions communautaire nous avons configuré un temps de cache négatif en plus d’une instruction pragma no cache afin d’être actualisé à chaque affichage.

Nos paramètre sont donc les suivants (extrait):

<span style="color: #66cc66;">[</span>HTTPHeaderSettings<span style="color: #66cc66;">]</span> CustomHeader<span style="color: #66cc66;">=</span>enabled Cache<span style="color: #66cc66;">-</span>Control<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> Cache<span style="color: #66cc66;">-</span>Control<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">public</span><span style="color: #66cc66;">,</span>must<span style="color: #66cc66;">-</span>revalidate Cache<span style="color: #66cc66;">-</span>Control<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>potins<span style="color: #66cc66;">-</span>people<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">public</span><span style="color: #66cc66;">,</span>must<span style="color: #66cc66;">-</span>revalidate <span style="color: #66cc66;">...</span> Cache<span style="color: #66cc66;">-</span>Control<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>communaute<span style="color: #66cc66;">/</span>espace<span style="color: #66cc66;">-</span>prive<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span>no<span style="color: #66cc66;">-</span>cache<span style="color: #66cc66;">,</span>must<span style="color: #66cc66;">-</span>revalidate Cache<span style="color: #66cc66;">-</span>Control<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>rss<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">public</span><span style="color: #66cc66;">,</span>must<span style="color: #66cc66;">-</span>revalidate Cache<span style="color: #66cc66;">-</span>Control<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>prismaatom<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">public</span><span style="color: #66cc66;">,</span>must<span style="color: #66cc66;">-</span>revalidate   Expires<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> Expires<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">300</span> Expires<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>potins<span style="color: #66cc66;">-</span>people<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">900</span> <span style="color: #66cc66;">...</span> Expires<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>communaute<span style="color: #66cc66;">/</span>espace<span style="color: #66cc66;">-</span>prive<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">-7200</span> Expires<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>rss<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">900</span> Expires<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>prismaatom<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">900</span>   Pragma<span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> Pragma<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span><span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span> Pragma<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>potins<span style="color: #66cc66;">-</span>people<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span> <span style="color: #66cc66;">...</span> Pragma<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>communaute<span style="color: #66cc66;">/</span>espace<span style="color: #66cc66;">-</span>prive<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span>no<span style="color: #66cc66;">-</span>cache Pragma<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>rss<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span> Pragma<span style="color: #66cc66;">[</span><span style="color: #66cc66;">/</span>prismaatom<span style="color: #66cc66;">]</span><span style="color: #66cc66;">=</span>

Hearder HTTP Home page Voici.fr

Header HTTP de la home page de Voici.fr

 

Taches a la charge du responsable d’hébergement ou administrateur système.

L’administrateur système n’est pas exempt de tache. En tant que responsable de l’hébergement et donc de la configuration serveur il doit mettre en oeuvre la couche LAMP. D’un point de vue système les besoins de eZ Publish sont important au point que la limite entre l’application et le système m’apparais bien flou, surtout si vous visez la haute performance.

Concernant apache il est nécessaire de le configurer avec un vhost comportant un certain nombre de paramètre précis. Entre autre l’utilisation du mod_rewrite est systèmatique avec eZ Publish. En effet tout appel de page doit ce faire au travers du index.php de l’application et uniquement par lui. Tout autre appel de ressources devant être appelé directement et de façon statique.

Le Vhost apache eZ Publish

De ce fait le vhost par défaut de eZ publish tel qu’il est recommandé dans la documentation de la version 4 ressemble à ceci :

<span style="color: #00007f;">NameVirtualHost</span> <span style="color: #ff0000;">128.39</span><span style="color: #ff0000;">.140</span><span style="color: #ff0000;">.28</span>   &lt;VirtualHost <span style="color: #ff0000;">128.39</span><span style="color: #ff0000;">.140</span><span style="color: #ff0000;">.28</span>&gt;     &lt;Directory /var/www/example&gt;         <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">FollowSymLinks</span>         <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">None</span>     &lt;/Directory&gt;       &lt;IfModule mod_php5.c&gt;         php_admin_flag safe_mode <span style="color: #0000ff;">Off</span>         php_admin_value register_globals    <span style="color: #ff0000;">0</span>         php_value magic_quotes_gpc  <span style="color: #ff0000;">0</span>         php_value magic_quotes_runtime  <span style="color: #ff0000;">0</span>         php_value allow_call_time_pass_reference <span style="color: #ff0000;">0</span>     &lt;/IfModule&gt;       <span style="color: #00007f;">DirectoryIndex</span> index.php       &lt;IfModule mod_rewrite.c&gt;         <span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>         <span style="color: #00007f;">RewriteRule</span> content/treemenu/? /index_treemenu.php <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">Rewriterule</span> ^/var/storage/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">Rewriterule</span> ^/var/<span style="color: #66cc66;">[</span>^/<span style="color: #66cc66;">]</span>+/storage/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">RewriteRule</span> ^/var/cache/texttoimage/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">RewriteRule</span> ^/var/<span style="color: #66cc66;">[</span>^/<span style="color: #66cc66;">]</span>+/cache/texttoimage/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">Rewriterule</span> ^/design/<span style="color: #66cc66;">[</span>^/<span style="color: #66cc66;">]</span>+/<span style="color: #66cc66;">(</span>stylesheets|images|javascript<span style="color: #66cc66;">)</span>/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">Rewriterule</span> ^/share/icons/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">Rewriterule</span> ^/extension/<span style="color: #66cc66;">[</span>^/<span style="color: #66cc66;">]</span>+/design/<span style="color: #66cc66;">[</span>^/<span style="color: #66cc66;">]</span>+/<span style="color: #66cc66;">(</span>stylesheets|images|javascripts?<span style="color: #66cc66;">)</span>/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">Rewriterule</span> ^/packages/styles/.+/<span style="color: #66cc66;">(</span>stylesheets|images|javascript<span style="color: #66cc66;">)</span>/<span style="color: #66cc66;">[</span>^/<span style="color: #66cc66;">]</span>+/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">RewriteRule</span> ^/packages/styles/.+/thumbnail/.* - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">RewriteRule</span> ^/favicon\.ico - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #00007f;">RewriteRule</span> ^/robots\.txt - <span style="color: #66cc66;">[</span>L<span style="color: #66cc66;">]</span>         <span style="color: #adadad; font-style: italic;"># Uncomment the following lines when using popup style debug.</span>         <span style="color: #adadad; font-style: italic;"># RewriteRule ^/var/cache/debug\.html.* - [L]</span>         <span style="color: #adadad; font-style: italic;"># RewriteRule ^/var/[^/]+/cache/debug\.html.* - [L]</span>         <span style="color: #00007f;">RewriteRule</span> .* /index.php     &lt;/IfModule&gt;       <span style="color: #00007f;">DocumentRoot</span> /var/www/<span style="color: #00007f;">example</span>     <span style="color: #00007f;">ServerName</span> www.<span style="color: #00007f;">example</span>.com     <span style="color: #00007f;">ServerAlias</span> admin.<span style="color: #00007f;">example</span>.com &lt;/VirtualHost&gt;

Or si le mod_rewrite et les expression régulières ne vous sont pas trop inconnues vous constaterez que tout appel d’image, de css ou de javascript pour le design du site comme ceux du contenue publié bénéficie d’exclusion à la régle de redirection final vers le index.php.

Du fait de ces exclusion les image, css et javascript sont directement fournit par apache sans que les paramètres de configuration des headers du protocole http tel que configuré par le développeur ou responsable d’application ne soit pris en compte.

Le Vhost apache eZ Publish pour Voici.fr

Afin de configurer les headers du protocole HTTP en réponse à chaque requête image, css et javascript il est nécéssaire de mettre en oeuvre des mécanismes propre à apache. L’enjeux est d’importance au regard du poids de l’image dans la volume total d’une page web.

 

Mod_expires pour Voici.fr, ne jeter plus les images après usage

Afin de configurer les header HTTP avec les instructions de mise à cache nous avons utilisé le mod_expire en précisant pour chaque type mime un temps de vie. Dans le cas de notre site nous avons inclus le block suivant dans le vhost apache de voici.fr.

&lt;IfModule mod_expires.c&gt;                 <span style="color: #00007f;">ExpiresActive</span> <span style="color: #0000ff;">on</span>                   <span style="color: #00007f;">ExpiresByType</span> text/css <span style="color: #7f007f;">"access 1 days"</span>                 <span style="color: #00007f;">ExpiresByType</span> application/x-javascript <span style="color: #7f007f;">"access 1 days"</span>                 <span style="color: #00007f;">ExpiresByType</span> text/javascript <span style="color: #7f007f;">"access 1 days"</span>                 <span style="color: #00007f;">ExpiresByType</span> image/gif <span style="color: #7f007f;">"access 1 days"</span>                 <span style="color: #00007f;">ExpiresByType</span> image/jpeg <span style="color: #7f007f;">"access 1 days"</span>                 <span style="color: #00007f;">ExpiresByType</span> image/png <span style="color: #7f007f;">"access 1 days"</span>         &lt;/IfModule&gt;

Hearder HTTP logo Voici.fr

Header HTTP du logo de Voici.fr

 

Mod_gzip pour Voici.fr, le régime des css

Dans le cas de voici.fr nous recherchions à limiter la sollicitation de nos serveurs mais également bande passante utilisée, l’utilisation des headers HTTP est une solution efficace et performante.

Mais nous avons constaté un autre phénomène lié à la vie médiatique du site. La dynamique d’un site comme voici.fr impose des modifications de style, de présentation et de format en continue pour ce distingué de la concurrence répondre au demande SEO ou tout simplement faire « vivre » le site. Une telle vie trépidante à conduit à un hyper croissance des fichiers css.

A chaque nouvelle charte graphique ou mise à jour les fichiers css grossissaient de nouvelle instruction de design. De l’habillage original les têtes de rubrique on commencé à changé, puis le format des articles, plus les formats des videos etc.. D’un css A nous avions maintenant en plus A1 pour les têtes de rubrique, A2 pour les articles, A3 pour les vidéos et ainsi de suite. Chaque css comportant ça propre présentation de balise html courante, chaque webdesigner a ajouter sa patte sans toucher à ce qui a été réalisé précédemment. Un final, dans un tel cas, le fichier css peux atteindre des tailles respectable de l’ordre de 500Ko[3].

Notre solution le mod_gzip qui permet à apache avant de délivrer un fichier css de le zipper. Nous l’avons configuré de façon à ne travailler que sur des fichiers de taille pertinente (ni top gros ni trop petit). Nous l’avons configuré pour qu’il ne zippe que les fichiers texte du type mime css ou javascript.

&lt;IfModule mod_gzip.c&gt; 		mod_gzip_on Yes 		mod_gzip_can_negotiate Yes 		mod_gzip_static_suffix .gz 		<span style="color: #00007f;">AddEncoding</span> gzip .gz 		mod_gzip_update_static No 		mod_gzip_command_version <span style="color: #7f007f;">'/mod_gzip_status'</span> 		mod_gzip_temp_dir /tmp 		mod_gzip_keep_workfiles No 		mod_gzip_minimum_file_size <span style="color: #ff0000;">500</span> 		mod_gzip_maximum_file_size <span style="color: #ff0000;">1000000</span> 		mod_gzip_maximum_inmem_size <span style="color: #ff0000;">60000</span> 		mod_gzip_min_http <span style="color: #ff0000;">1000</span> 		mod_gzip_handle_methods GET POST   		mod_gzip_item_include mime ^text/css$ 		mod_gzip_item_include mime ^text/javascript$ 		mod_gzip_item_include mime ^application/x-javascript$   		mod_gzip_dechunk Yes 		mod_gzip_add_header_count Yes 		mod_gzip_send_vary Yes 	&lt;/IfModule&gt;

Poids Css voici.fr

Poids des css dans la home de Voici.fr

 

Conclusion en forme de scénario

Un internaute consultant le site voici.fr sollicitera nos serveurs pour l’intégralité des éléments de la première page appelée. Dès le seconde page les images et fichiers css du desing du site ne seront plus appelés, les instructions des hearder http donnant l’autorisation au navigateur de ce fournir dans son cache pour ces éléments la précisément, ceci durant 24 heures à partir de l’heure ou il à accédé pour la première fois à l’élément.
Concernant le code html constituant la page web il sera demandé à nos serveur à chaque nouvelle page. Mais si l’internaute retourne sur la home page durant les 5 minutes de temps de vie du cache le navigateur, tout comme pour les images, ce fournira sans son cache sans consulté les serveurs.
Passé 5 minutes toute nouvelle demande de la home page sur le navigateur généra un appel aux serveurs pour le code html, mais pas pour les images.

Il ne vous reste plus qu’a concevoir un architecture de reverse proxy en amont de vos serveurs pour garder en cache toute ces informations et éviter durant les périodes de temps de vie définir de sollicité vos serveurs.

Notes

[1] Linux Apache Mysql Php, pas de windows ici

[2] Attention a la logique de surcharge des fichier ini propre à eZ pulbish

[3] « Que ceux qui aiment Dreamweaver, les popups, les iframes, les Gifs, se retirent »

 

Simplement en suivant les conseils de Jean-Christophe Duvivier

J’ai configuré mon blog DC2 comme ceci

  • Panneau d’administration > Paramètres du Blog :
  • URL du Blog : L’url complète de votre blog (en ce qui me concerne : http://www.karlesnine.com/)
  • Méthode de lecture de l’url : Sélectionnez PATH_INFO
  • Enregistrez

J’ai évité d’utiliser le .htaccess et j’ai directement porté mes RewriteRule dans la vhost de mon apache 2 comme ceci :

&lt;VirtualHost *:<span style="color: #ff0000;">80</span>&gt; 	 <span style="color: #00007f;">ServerName</span> www.karlesnine.com 	 <span style="color: #00007f;">ServerAlias</span> karlesnine.com 	 <span style="color: #00007f;">DocumentRoot</span> /var/www/karlesnine.com 	 <span style="color: #00007f;">ErrorLog</span> /var/log/apache/error.log 	 <span style="color: #00007f;">CustomLog</span> /var/log/apache/access.log combined &nbsp; 	<span style="color: #adadad; font-style: italic;"># DirectoryIndex index.php</span> &nbsp; 	<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span> 	<span style="color: #00007f;">RewriteLog</span> <span style="color: #7f007f;">&quot;/var/log/apache/rewrite.log&quot;</span>         <span style="color: #00007f;">RewriteLogLevel</span> <span style="color: #ff0000;">0</span> &nbsp; 	<span style="color: #adadad; font-style: italic;"># Special spam commentaire .ru .china .jp</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">81</span>\.<span style="color: #ff0000;">177</span>\.<span style="color: #ff0000;">14</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>        <span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">81</span>\.<span style="color: #ff0000;">177</span>\.<span style="color: #ff0000;">15</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>        <span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">121</span>\.<span style="color: #ff0000;">14</span>\.<span style="color: #ff0000;">75</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">210</span>\.<span style="color: #ff0000;">159</span>\.<span style="color: #ff0000;">140</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">210</span>\.<span style="color: #ff0000;">136</span>\.<span style="color: #ff0000;">18</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">59</span>\.<span style="color: #ff0000;">157</span>\.<span style="color: #ff0000;">220</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">59</span>\.<span style="color: #ff0000;">156</span>\.<span style="color: #ff0000;">227</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">222</span>\.<span style="color: #ff0000;">229</span>.\<span style="color: #ff0000;">216</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">203</span>\.<span style="color: #ff0000;">141</span>\.<span style="color: #ff0000;">129</span>\.<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">0</span><span style="color: #ff0000;">-255</span><span style="color: #66cc66;">&#93;</span>	<span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>         <span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REMOTE_ADDR<span style="color: #66cc66;">&#125;</span> ^<span style="color: #ff0000;">59</span>\.<span style="color: #ff0000;">157</span>\.<span style="color: #ff0000;">220</span>\. 	<span style="color: #00007f;">RewriteRule</span> .* -                                        <span style="color: #66cc66;">&#91;</span>F,L<span style="color: #66cc66;">&#93;</span> &nbsp; &nbsp; 	<span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> !^<span style="color: #66cc66;">&#40;</span>/admin/|/cache/|/db/|/images/|/inc/|locales/|/plugins/<span style="color: #66cc66;">&#41;</span> 	<span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> !^<span style="color: #66cc66;">&#40;</span>/favicon.ico/|/icons/|/local/|/dotclear/|/themes/|/public/<span style="color: #66cc66;">&#41;</span> 	<span style="color: #00007f;">RewriteCond</span> %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> !^/index.php 	<span style="color: #00007f;">RewriteRule</span> <span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span>$ /index.php/$<span style="color: #ff0000;">1</span> &nbsp; &lt;/VirtualHost&gt;

J’ai découpe la ligne de RewriteCond en deux pour une question de lecture. J’ai ajouter quelque condition entre autre sur favicon.ico qui malgré le plugin myfavicon n’apparaissait pas.

© 2012 Karlesnine Suffusion theme by Sayontan Sinha