Modifications entre les versions 12 et 13
Version 12 à la date du 2016-09-27 14:07:02
Taille: 6216
Éditeur: LionelValentin
Commentaire:
Version 13 à la date du 2016-09-27 19:08:22
Taille: 6489
Éditeur: LionelValentin
Commentaire:
Texte supprimé. Texte ajouté.
Ligne 188: Ligne 188:
 location / {

  if ($args ~ q=user){
   rewrite ^ http://prod-drupal01-idneuf.vpc02.auf/ permanent;
  }

  if ($args ~ q=admin){
   rewrite ^ http://prod-drupal01-idneuf.vpc02.auf/ permanent;
  }

  proxy_set_header Host prod-proxy-vip.vpc02.auf;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_pass http://proxy-idneuf;
 }

 location /admin {
  proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  rewrite ^/(.*)$ http://prod-drupal01-idneuf.vpc02.auf/$1 permanent;
 }

 location /user {
  proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  rewrite ^/(.*)$ http://prod-drupal01-idneuf.vpc02.auf/$1 permanent;
 }

        location / {

                if ($args ~ q=user){
                        rewrite ^$ http://prod-proxy-vip.vpc02.auf/user permanent;
                }

                if ($args ~ q=admin){
                        rewrite ^$ http://prod-proxy-vip.vpc02.auf/admin permanent;
                }

                proxy_set_header Host prod-proxy-vip.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://proxy-idneuf;
        }

        location /admin {
                proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://prod-drupal01-idneuf.vpc02.auf;
        }

        location /user {
                proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://prod-drupal01-idneuf.vpc02.auf;
        }

Rédiger « OVH/VPC02/idneuf/Drupal » ici.

Installation des paquets

apt-get install apache2 haproxy php5 php5-gd php5-durl libssh2-php php5-memcache memcached

Configuration d'HAProxy

Contenu du fichier : /etc/haproxy/haproxy.cfg :

global
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy
        daemon


defaults
        log     global
        mode    tcp
        option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000

listen mysql-cluster
        bind 127.0.0.1:3306
        mode tcp
        option mysql-check user haproxy
        balance roundrobin
        server prod-db02-idneuf prod-db02-idneuf:3306 check
        server prod-db03-idneuf prod-db03-idneuf:3306 check

Configuration des serveurs slaves

Sur chaque serveur slave, exécuter les commandes SQL suivante :

INSERT INTO mysql.user (Host,User) values ('prod-drupal02-idneuf','haproxy'); FLUSH PRIVILEGES;

Cette commande va permettre a HAProxy de pourvoir tester la disponibilité du serveur via le check définie dans la configuration d'HAProxy (option mysql-check user haproxy)

Il faut ensuite créer un utilisateur en lecture seule pour la connexion de Drupal.

Sur le master, exécuter la commande SQL suivante :

grant select on drupal.* to 'haproxy_auf'@'%' identified by 'xxxxxxxxxxx';
flush privileges;

Utilisation de HAProxy avec Drupal

Dans le fichier sites/default/settings.php, insérer les lignes suivantes :

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'drupal',
      'username' => 'haproxy_auf',
      'password' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      'host' => '127.0.0.1',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
      'readonly' => TRUE ,
    ),
  ),
);

/!\ Le host ne doit pas être "localhost" sinon la connexion ne se fera pas.

Installation de memcache

Dans le fichier /etc/memcache.conf, configurer la quantité de RAM a allouer :

# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
-m 1024

Configuration de Drupal

Installer le module suivant depuis l'interface d'administration :

https://ftp.drupal.org/files/projects/memcache-7.x-1.5.tar.gz

Dans le fichier sites/default/settings.php, insérer les lignes suivantes :

//Use memcache
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_inc'] = 'sites/all/modules/contrib/memcache/memcache.inc';

//Memcache session
$conf['session_inc'] = 'sites/all/modules/memcache/unstable/memcache-session.inc';

//Memcache lock
$conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc';

//Add in stampede protection
$conf['memcache_stampede_protection'] = TRUE;

//Don't bootstrap the database when serving pages from the cache.
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;

Lien avec ORI-OAI

Fichiers a modifier afin de faire le lien vers ORI-OAI :

ori-oai-search-idneuf.css

http_header/index.php

sites/default/files/xmlsitemap/Xh****************************wOM/1.xml 

sites/all/themes/theme1005/templates/views-view—block₁--block.tpl.php

sites/all/themes/theme1005/css/style-header-footer.css

sites/all/themes/theme1005/css/custom.css

Utilisation de NginX comme ReverseProxy

Installation

Se referer a la documentation : AUF - PROCÉDURE D'INSTALLATION DU REVERSE PROXY IDNEUF.

Configurer un site comportant un cluster

Dans le fichier de configuration du site :

upstream proxy-idneuf {
        ip_hash;
        server prod-drupal02-idneuf.vpc02.auf;
        server prod-drupal03-idneuf.vpc02.auf;
}

server {

        listen 80;
        listen [::]:80;

        server_name prod-prox-vip.vpc02.auf;
        #server_name prod-proxy01.vpc02.auf;
        #server_name idneuf.org;
        #server_name ori-oai.idneuf.org;
        
        root /var/www/html/;
        
        # log level
        #error_log /var/log/nginx/prod-proxy01.vpc02.auf.error debug; #debug

        error_log /var/log/nginx/prod-proxy01.vpc02.auf.error; #normal


        location / {

                if ($args ~ q=user){
                        rewrite ^$ http://prod-proxy-vip.vpc02.auf/user permanent;
                }

                if ($args ~ q=admin){
                        rewrite ^$ http://prod-proxy-vip.vpc02.auf/admin permanent;
                }

                proxy_set_header Host prod-proxy-vip.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://proxy-idneuf;
        }

        location /admin {
                proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://prod-drupal01-idneuf.vpc02.auf;
        }

        location /user {
                proxy_set_header Host prod-drupal01-idneuf.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://prod-drupal01-idneuf.vpc02.auf;
        }

        location /ressources/ {
                #try_files $uri $uri/ $uri/index.html =404;
                proxy_set_header Host prod-proxy-vip.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://prod-ori-oai01-idneuf.vpc02.auf;
        }

        location /ori-oai-thumbnail/ {
                proxy_set_header Host prod-proxy-vip.vpc02.auf;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://prod-ori-oai01-idneuf.vpc02.auf;
        }

}

L'option ip_hash permet de conserver la connexion de chaque client sur le même serveur.

Config pour récupérer le X-Forward-For

Modifier le fichier sites/default/settings.php :

$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array('1.1.1.1','1.1.1.2');

OVH/VPC02/idneuf/Drupal (dernière édition le 2016-10-06 18:47:41 par LionelValentin)