moar english

This commit is contained in:
Jérémy Lecour 2022-10-04 09:05:57 +02:00 committed by Jérémy Lecour
parent 75d86e62c2
commit 9d6050ecd5

View file

@ -174,18 +174,20 @@ And we can combine several of these conditions together:
### What for?
L'utilisation du PROXY protocol n'est pas du tout indispensable, mais elle ajoute un confort significatif dans la gestion de toute cette chaîne.
Using the PROXY Protocol is not a necessity at all, but it adds a certain amount of comfort when we have proxies involved, like HAProxy and Varnish.
Dans leur rôle de proxy intermédiaire, HAProxy et Varnish sont vus comme des clients au niveau TCP ; entre eux, mais surtout vis-à-vis du serveur web final. Si on ne fait rien de particulier,le serveur final verra toujours l'IP d'HAProxy comme IP du client. Ça rend impossible l'application dautorisations ou restrictions par IP. Ça rend difficile le suivi des requêtes, les statistiques…
At the TCP level, when HAProxy talks to Varnish, then Varnish to HAproxy and finally HAroxy to the final web server, they are all seen as regular HTTP clients.
Without any modification, each element reports the IP of the previous elements as the client IP, and the final server thinks that HAProxy is the only client accessing it. It's bad for IP based filtering, logging…
Vous me direz qu'on a pour ça l'en-tête HTTP `X-Forwarded-For`, mais elle est invisible au niveau TCP, et sa prise en compte au niveau applicatif n'est pas toujours facile, voire possible.
At the HTTP level, we've had the `X-Forwarded-For` header for a long time. I you look at its presence and you know how to parse it, you can use the ocrrect value in your web-server of application. It's cumbersome, and error-prone, and at the TCP level, this is invisible.
Le PROXY protocol est une simple extension de TCP qui permet d'ajouter cette notion d'IP réelle du client.
Cela impose que les 2 parties de l'échange sachent gérer cette extension, mais à partir de là il n'est plus besoin de le gérer dans la couche applicative.
The PROXY protocol is simple extension of the TCP protocol. It add the same kinf of header, but at the TCP level. The downside is that both parties must support the PROXY protocol andbe configured to use it. The upside is that its completely transparent after that. There is nothing to do at the application level.
The PROXY protol has been designed by Willy Tarreau, creator of HAProxy, in 2010. It has sincebeen adopted by many products like Varnish, Apache, Nginx, Postfix, Docecot…
### Comment?
Au niveau HAProxy, nous retrouvons celà dans le backend qui transmet à Varnish, dans le frontend de retour depuis Varnish et éventuellement dans le backend qui transmet au serveur web final.
In HAProxy we find in the backend to Varnish, in the frontend used by Varnish to pass the request to HAProxy, and possibly ibn the backend to the final web-servers.
```
backend varnish
@ -198,16 +200,15 @@ backend example_com
server example-hostname 1.2.3.4:443 check observe layer4 ssl verify none send-proxy-v2
```
Lorsqu'HAProxy est client on ajoute `send-proxy-v2` et lorsqu'il est serveur on ajoute `accept-proxy`.
With HAProxy, for the listening side we use the `accept-proxy` option in the frontend section and for the emitting side we use the `send-proxy-v2` option in the backendsection.
Pour Varnish, l'écoute se gère dans la ligne de commande de démarrage avec l'option `PROXY` :
With Varnish, for the listening side we use the `PROXY` option in the startp command line :
```
/usr/sbin/varnishd […] -a /run/varnish.sock,PROXY […]
```
Et pour le retour vers HAProxy, c'est dans la configuration, avec l'option `proxy_header = 1` :
And for the emitting side, we use the `proxy_header = 1` setting in the backend section. :
```
backend default {
@ -217,17 +218,20 @@ backend default {
}
```
### Debug sans PROXY protocol
### How to debug with PROXY protocol
Bien que ça soit une optimisation très appréciable, elle n'est pas compatible avec de nombreux outils qui peuvent avoir besoin de se connecter à HAProxy ou Varnish de manière classique.
Even though it's a valuable optimization, the PROXY protocol is not supported by many tools, especially some very low level ones, like a forged HTTP request on a telnet connection.
C'est particulièrement utile au niveau de Varnish pour faire du debug sans passer par HAProxy. On ajoute alors à la ligne de commande de démarrage un autre point d'entrée. Nous le faisons uniquement en local, sur un port inaccessible à l'extérieur :
This is especially if you want to bypass HAProxy and debug at the varnish level directly.
The startup command accepts many listening addresses, each one with its options.
We can add one restricted on localhost and a custom firewalled port, and have a debug back-door :
```
/usr/sbin/varnishd […] -a 127.0.0.1:82 […]
```
Il devient alors très facile de faire une requête directe :
It become really easy to make a direct request:
```
curl --verbose \
@ -236,9 +240,10 @@ curl --verbose \
http://www.example.com:82/foo/bar
```
Alors oui, curl supporte le PROXY protocol depuis laversion 7.37.0 avec l'option `--proxy-header`, mais c'est un exemple.
And yes, curl supports the PROXY protocol since version 7.37.0 and with the `--proxy-header`.
But it's an example and it's good to know that you can do that manually if you want or need.
### Jusqu'au serveur final
### What about the final servers?
Si on contrôle les serveurs web finaux et qu'il ssont compatibles, on peut aussi faire la liaison finale avec le PROXY protocol. On sera alors aussi tenté d'ajouter au serveur web un port d'écoute sans PROXY protocol, et bien protégé.