Hi,

On Sat, May 06, Ciprian Dorin Craciun wrote:
> Hello all!
> 
> In last weeks I've started encountering a problem, that for our
> particular use-case is seriously breaking some of our sites, namely:
> 
> * a client makes a POST request which has a "largish" payload, one
> that does not manage to "push" it through before HAProxy has a chance
> to respond,
> * if HAProxy is configured to redirect such a request (like for
> example upgrading HTTP to HTTPS),
> * then HAProxy responds with the redirect, and closes the connection;
> but the client has not yet been able to push its POST body and
> receives a write error, and thus it aborts without trying to read the
> response from HAProxy;
> 
> 
> One can easily reproduce this with:
> (
>   printf -- 'POST /invalid HTTP/1.1\r\nHost: invalid.example.com\r\n\r\n'
>   dd if=/dev/urandom bs=1024 count=4 | base64
> ) \
> | socat -d -d -v tcp:127.0.0.1:80,sndbuf=16 stdio
> 
> , which results in a connection reset, as `socat` is trying to push
> data to a closed socket.
> 
> (Via private email I can give an actual `tcpdump` capture with production 
> data.)
> 
> 
> 
> 
> Unfortunately this issue doesn't impact a "random" client but recent
> versions of Firefox and Chrome, which just display a "connection
> reset" kind of message to the users.

My firefox(52.1 on linux) was able to send 128k file,
but 800k file results in connection reset. My chrome sent 16k file, but
fails (ERR_CONNECTION_RESET) on 17k file (few times even the 17k file
worked).
(tested with haproxy 1.8dev version).
(curl seems to handle 800k file upload ok, wget seems to work upto 64k
(very limited testing)).

This http-response set-status (ugly hack/workaround) might keep chrome/firefox
happy:
frontend test
        bind [email protected]:80
        bind [email protected]:443 ssl crt ./crt.pem
        acl is_plain dst_port 80
        redirect scheme https code 302 if is_plain !METH_POST
        default_backend test_be

backend test_be
        acl is_plain dst_port 80
        http-response set-status 302 reason "found\r\nLocation: 
https://127.0.0.1/invalid"; if METH_POST is_plain

It might be possible to use vars to have dynamic Location:
Frontend:
http-request set-header X-DUMMY 
"https://"%[req.hdr(Host),regsub(:.+$,,g)]":443"%[path]
http-request set-var(sess.loc) hdr(X-DUMMY)

Backend:
http-response redirect code 302 location %[var(sess.loc)] if METH_POST is_plain

-Jarno

-- 
Jarno Huuskonen

Reply via email to