Proxies, Caches et Multiplexeurs

solution :
80 : Varnish --> 443
443 : SSLH --> POUND --> Varnish --> Apache --> PHP/autres (ancienne config)

443 : SSLH --> NGINX --> Varnish --> Apache --> PHP/Gateone/autres (nouvelle config, websocket proof)

02/01/2014 : les websockets ne sont pas supportées par pound pour le moment donc la solution n'est pas optimale mais les autres solutions ne me permettent pas d'utiliser le X-Forward-For pour avoir l'IP client dans les logs, ce qui est plus important à mes yeux qu'une console virtuelle dans un navigateur.

maj du 10/06/2014 : nginx supporte les websockets et l'utilisation du X-Forward-For, donc c'est la solution mise en place pour le moment. il est un peu moins efficace pour le SSL que pound mais pour un petit serveur, il tiendra très bien la charge.

----------------------------------------------------------------------------------------------
Plusieurs solutions testées:


  • SSLH + Apache : OK mais log en 127.0.0.1 (SSH passe le proxy d'entreprise)
  • SSLH + Varnish (port 80 uniquement) + Apache (avec SSL) : OK mais log en 127.0.0.1 et varnish ne cache que la version HTTP
  • Varnish (port 80 uniquement) + Apache (Avec SSL) : OK mais varnish ne cache que la version HTTP et SSH ne passe plus les proxy d'entreprise
  • HAproxy (port 80 et 443) + Apache (sans SSL) : OK mais pas de cache et SSH ne passe plus les proxy d'entreprise
  • SSLH + HAproxy (port 80 et 443) + Apache (sans SSL) : OK mais pas de cache (websockets OK de mémoire)
à tester:

  • SSLH (--transparent + règle IPTABLE pour les logs) + Pound (pour le SSL) + varnish (pour le cache) + Apache (sans SSL) : OK
  • SSHTTP (avec l'option transparent proxy) : je ne sais pas encore.
  • SSLH (--transparent + règle IPTABLE pour les logs) + NGINX(pour le SSL et la gestion des websockets) + varnish (pour le cache) + Apache (sans SSL) : Tout OK, même les websockets!

Ajout du README de sslh 1.16 :

On Linux (only?), you can compile sslh with USELIBCAP=1 to make use of POSIX capabilities; this will save the required capabilities needed for transparent proxying for unprivileged processes.
Alternatively, you may use filesystem capabilities instead of starting sslh as root and asking it to drop privileges. You will need CAP_NET_BIND_SERVICE for listening on port 443 and CAP_NET_ADMIN for transparent proxying (seecapabilities(7)).

You can use the setcap(8) utility to give these capabilities to the executable:

# setcap cap_net_bind_service,cap_net_admin+pe sslh-select 

Then you can run sslh-select as an unpriviledged user, e.g.:

$ sslh-select -p myname:443 --ssh localhost:22 --ssl localhost:443 

Caveat: CAP_NET_ADMIN does give sslh too many rights, e.g. configuring the interface. If you're not going to use transparent proxying, just don't use it (or use the libcap method).


extrait du README de sslh 1.15 :

Transparent proxy support

On Linux (only?) you can use the --transparent option to request transparent proying. This means services behind sslh (Apache, sshd and so on) will see the external IP and ports as if the external world connected directly to them. This simplifies IP-based access control (or makes it possible at all).

sslh needs extended rights to perform this: you'll need to give it CAP_NET_ADMIN capabilities (see appropriate chapter) or run it as root (but don't do that).

The firewalling tables also need to be adjusted as follow. The example connects to HTTPS on 4443 -- adapt to your needs ; I don't think it is possible to have httpd listen to 443 in this scheme -- let me know if you manage that:

# iptables -t mangle -N SSLH 
# iptables -t mangle -A OUTPUT --protocol tcp --out-interface eth0 --sport 22 --jump SSLH
# iptables -t mangle -A OUTPUT --protocol tcp --out-interface eth0 --sport 4443 --jump SSLH
# iptables -t mangle -A SSLH --jump MARK --set-mark 0x1
# iptables -t mangle -A SSLH --jump ACCEPT
# ip rule add fwmark 0x1 lookup 100
# ip route add local 0.0.0.0/0 dev lo table 100 

This will only work if sslh does not use any loopback addresses (no 127.0.0.1 or localhost ), you'll need to use explicit IP addresses (or names):

 sslh --listen 192.168.0.1:443 --ssh 192.168.0.1:22 --ssl 192.168.0.1:4443   

This will not work:

 sslh --listen 192.168.0.1:443 --ssh 127.0.0.1:22 --ssl 127.0.0.1:4443