BUG/MEDIUM: http: Drop the connection establishment when a redirect is performed
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 20 Apr 2017 12:16:13 +0000 (14:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Apr 2017 05:37:45 +0000 (07:37 +0200)
commit9f724edbd8d1cf595d4177c3612607f395b4380e
treefa01d90df0b4b9bde544699498149fdd4beaa639
parent7d8e6889536f38c00e70c4187397d1c4d009aeae
BUG/MEDIUM: http: Drop the connection establishment when a redirect is performed

This bug occurs when a redirect rule is applied during the request analysis on a
persistent connection, on a proxy without any server. This means, in a frontend
section or in a listen/backend section with no "server" line.

Because the transaction processing is shortened, no server can be selected to
perform the connection. So if we try to establish it, this fails and a 503 error
is returned, while a 3XX was already sent. So, in this case, HAProxy generates 2
replies and only the first one is expected.

Here is the configuration snippet to easily reproduce the problem:

    listen www
        bind :8080
        mode http
        timeout connect 5s
        timeout client 3s
        timeout server 6s
        redirect location /

A simple HTTP/1.1 request without body will trigger the bug:

    $ telnet 0 8080
    Trying 0.0.0.0...
    Connected to 0.
    Escape character is '^]'.
    GET / HTTP/1.1

    HTTP/1.1 302 Found
    Cache-Control: no-cache
    Content-length: 0
    Location: /

    HTTP/1.0 503 Service Unavailable
    Cache-Control: no-cache
    Connection: close
    Content-Type: text/html

    <html><body><h1>503 Service Unavailable</h1>
    No server is available to handle this request.
    </body></html>
    Connection closed by foreign host.

[wt: only 1.8-dev is impacted though the bug is present in older ones]
src/proto_http.c