On Wed, Jun 02, 2010 at 04:18:33PM +0100, Laurie Young wrote:
> Hi everyone
> 
> I have a problem, and I'm not sure if HAProxy can solve it
> 
> I have a range of different requests coming in on a server to port 80, and
> am using HAProxy to switch them to the relevant back end servers.
> 
> Most of these requests are HTTP requests and I have layer 7 mode working
> fine, doing everything i need
> 
> Now I have to also send a tcp request though the same port. I need HAProxy
> to detect if it is a tcp request, and if so route it to server 1, otherwise
> parse the HTTP and work out which server to use based on the HTTP content
> 
> Is this possible?

Yes this is possible with version 1.4. For this you need to have a TCP
frontend and an HTTP backend. Using tcp inspection rules, you define
how long you wait for an HTTP request. If a valid HTTP request comes
in time, you switch to the HTTP backend. If none comes in time, of if
the traffic is not HTTP, then you use the TCP backend. Some people use
this to open SSH on port 80 or 443 ;-)

However there are some drawbacks. Since the logs are defined by the
frontend, you won't benefit from HTTP logging, you'll only have TCP
logging.

Also, if you want to try this, you should upgrade to 1.4.7 (which is
not yet released but available as a snapshot) because it fixes an
issue with the HTTP protocol detection. One field was not properly
initialized, so once HTTP was detected on a connection, it was likely
that further connections would be detected as HTTP too.

Example of usage :

    frontend xxxx
        bind :80
        mode tcp
        option tcplog
        tcp-request inspect-delay 5s
        tcp-request content accept if HTTP
        use_backend http_backend if HTTP
        default_backend tcp_backend

   backend tcp_backend
        # tcp-only config

   backend http_backend
        # http-only config
        mode http

Regards,
Willy


Reply via email to