Re: Proxied connections via SSH tunnel are up/down based on state of ssh tunnel not service

2012-07-23 Thread Jonathan Matthews
On 23 July 2012 03:59, Alex Soto aps...@gmail.com wrote:
 Hi,

 I've got a proxy connecting to two 'servers' that are connecting from the 
 HAProxy to the remote servers via an ssh tunnel.

 Here's an example:

 listen portal 127.0.0.1:8085
 mode tcp
 balance source
 timeout check 3000
 server i-e4014f9c localhost:58919 check
 server i-76a4ea0f localhost:38559 check

 localhost:58919 and localhost:38559 are forwarded to separate remote servers 
 via an SSH tunnel.

 What I'm seeing is that I can take down the remote service and HAProxy 
 doesn't detect it, but if I take down the ssh tunnel it detects it.  I'm 
 wondering if there is some configuration that I can do to have HAProxy detect 
 when the remote server's service goes down?

This is because you're only asking HAProxy to check SSH, i.e.
localhost:58919/38559. It doesn't know anything about the remote
service.

If the remote service is HTTP, you could add a httpchk line that
will determine if layer7 is working.
If not, there are some other protocols for which layer7 checks have
been implemented (mysql; pgsql(?); smtp) but, if you're not using
them, I'm not sure what to suggest.

As an aside, I can't imagine performance over SSH tunnels is
brilliant. Have you considered more transparent yet still secure
options, such as IPsec or (for ease of setup) OpenVPN? With those,
you'd have the advantage of being able to do TCP checks of the remote
port instead of a localhost one, without having to care about the
layer7 checks. Which isn't a /good/ thing - layer7 checks are the way
forward! But it helps if you're not talking a layer7 protocol that
HAProxy knows about.

HTH,
Jonathan
-- 
Jonathan Matthews
Oxford, London, UK
http://www.jpluscplusm.com/contact.html



Re: What's the different between http-server-close in frontend or in backends.

2012-07-23 Thread Willy Tarreau
Hi Jinge,

On Mon, Jul 23, 2012 at 11:17:42AM +0800, jinge wrote:
 Hi list.
 Sorry for my poor English.
 i use haproxy nowadays.But i just don't now thats the difference between
 http-server-close in frontend or in backends.Can someone help me?

They're similar. You need at least one on the path. In short, haproxy
does this (- means no option and * means any value other than
those explicitly specified) :

  frontend backend  result
 -- tunnel mode

  httpclose   - passive close
 - httpclosepassive close
  httpclosehttpclosepassive close

  httpclosehttp-server-closeforced close
  http-server-closehttpcloseforced close
  forceclose  * forced close
 * forceclose   forced close

  http-server-close   * http-server-close
 * http-server-closehttp-server-close

As you can see, the stronger close wins, and httpclose+server-close
correspond to force-close.

Regards,
Willy