From 821b0d23bd2fcce6c250b12b4b903ff446fad3c1 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 20 Jun 2017 18:33:17 +0200 Subject: [PATCH] un peu de nginx, varnish, haproxy --- reveal/httpd.html | 165 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 150 insertions(+), 15 deletions(-) diff --git a/reveal/httpd.html b/reveal/httpd.html index b69a9c2..936e022 100644 --- a/reveal/httpd.html +++ b/reveal/httpd.html @@ -362,37 +362,172 @@ RewriteRule ^/foo.txt [L,F]
-
-

NGINX

+
+

Nginx

+

Serveur web, alternative à Apache

+
-# aptitude install nginx +
+

Installation

+

+  # aptitude install nginx
+  # nginx -v
+  
+nginx version: nginx/1.10.3
+  
+
+
https://wiki.evolix.org/HowtoNginx -
+
-
-

HAPROXY

- -https://wiki.evolix.org/HowtoHaproxy +
+

HAProxy

+

Proxy et load-balancer TCP/HTTP/HTTPS

+ +
+

Installation

+

+  # apt install haproxy
+  # varnishd -v
+  
+HA-Proxy version 1.7.5-2 2017/05/17
+Copyright 2000-2017 Willy Tarreau <willy@haproxy.org>
+  
+
+ +
+

Configuration minimale

+

+global
+      log 127.0.0.1 local5 debug
+
+defaults
+      mode     http
+
+listen www
+      bind *:80
+      balance roundrobin
+      option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www.example.com
+      stats uri /haproxy-stats
+      stats auth foo:bar
+      server www00 192.0.2.1:80 maxconn 50 check inter 10s
+      server www01 192.0.2.2:80 maxconn 50 check inter 10s
+      
+
+ +
+

Configuration avancée

+
    +
  • gestion fine des performances
  • +
  • multiples IP/domaines écoutés
  • +
  • différents algorithmes de load-balancing
  • +
+
+ +
+

TLS/SSL

+
    +
  • terminaison SSL ou transmission transparente
  • +
  • multi certificats et SNI
  • +
  • agrafage OCSP facilitée
  • +
-
-

VARNISH

- -https://wiki.evolix.org/HowtoVarnish -
+

mode TCP

+

+listen memcached 127.0.0.1:11211
+    option tcp-check
+    server nosql00 192.0.2.3:11211 check
+    server nosql01 192.0.2.4:11211 check backup
+    
+

mode MySQL (simple)

+

+listen mysql 127.0.0.1:3306
+    mode tcp
+    option mysql-check user haproxy_check
+    server sql00 192.0.2.1:3306 check
+    
+
+
-

PHP

+

mode MySQL (avancé)

+ Si le test de connexion à MySQL ne suffit pas,
on indique un programme pour un test personnalisé
qui indiquera à HAProxy si le backend va bien. +
+ +
+

Dashboard

+ Une interface web permet de suivre l'état du proxy. +
+ +
+ +
+
+

Varnish

+

Accélérateur web : cache et reverse-proxy

+
+ +
+

Installation

+

+# apt install varnish
+# varnishd -V
+
+varnishd (varnish-4.0.2 revision bfe7cd1)
+Copyright (c) 2006 Verdens Gang AS
+Copyright (c) 2006-2014 Varnish Software AS
+
+
+ +
+

Configuration minimale

+

Varnish relaie les requêtes vers le port 8080 local.

+

+backend default {
+    .host = "127.0.0.1";
+    .port = "8080";
+}
+
+
+ +
+

Logs

+Par défaut les logs sont gardés en mémoire (taille fixe) pour les performances. +

+# varnishstat
+# varnishtop -i ReqURL
+# varnishlog
+# varnishnsca
+
+Filtres possibles +

+# varnishlog -q 'TxHeader eq MISS' -q "ReqHeader \
+             ~ '^Host: example\.com$'" | grep RxURL
+# varnishncsa -q "ReqHeader eq 'X-Cache: MISS'"
+
+
+ +
+

Syntaxe VCL

+
+ +
+ +
+
+

PHP

+

Langage de programmation très adapté au web.

+
https://wiki.evolix.org/HowtoLAMP/PHP -