haproxy icon indicating copy to clipboard operation
haproxy copied to clipboard

http/2 connections terminated (CD status), net::ERR_HTTP2_PROTOCOL_ERROR 200 in client

Open OliverKellyATech opened this issue 6 years ago • 9 comments

Please see https://www.mail-archive.com/[email protected]/msg38100.html

Output of haproxy -vv and uname -a

$ haproxy -vv
HA-Proxy version 1.8.26-1ppa1~bionic 2020/08/03
Copyright 2000-2020 Willy Tarreau <[email protected]>

Build options :
  TARGET  = linux2628
  CPU     = generic
  CC      = gcc
  CFLAGS  = -O2 -g -O2 -fdebug-prefix-map=/build/haproxy-0HEnDu/haproxy-1.8.26=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -Wno-null-dereference -Wno-unused-label -Wno-stringop-overflow
  OPTIONS = USE_GETADDRINFO=1 USE_ZLIB=1 USE_REGPARM=1 USE_OPENSSL=1 USE_LUA=1 USE_SYSTEMD=1 USE_PCRE2=1 USE_PCRE2_JIT=1 USE_NS=1

Default settings :
  maxconn = 2000, bufsize = 16384, maxrewrite = 1024, maxpollevents = 200

Built with OpenSSL version : OpenSSL 1.1.1  11 Sep 2018
Running on OpenSSL version : OpenSSL 1.1.1g  21 Apr 2020
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports : TLSv1.0 TLSv1.1 TLSv1.2 TLSv1.3
Built with Lua version : Lua 5.3.3
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND
Encrypted password support via crypt(3): yes
Built with multi-threading support.
Built with PCRE2 version : 10.31 2018-02-12
PCRE2 library supports JIT : yes
Built with zlib version : 1.2.11
Running on zlib version : 1.2.11
Compression algorithms supported : identity("identity"), deflate("deflate"), raw-deflate("deflate"), gzip("gzip")
Built with network namespace support.

Available polling systems :
      epoll : pref=300,  test result OK
       poll : pref=200,  test result OK
     select : pref=150,  test result OK
Total: 3 (3 usable), will use epoll.

Available filters :
	[SPOE] spoe
	[COMP] compression
	[TRACE] trace

$ uname -a
Linux XX 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

What's the configuration?

global
    log /dev/log    local0
    #log /dev/log    local1 notice
    chroot /var/lib/haproxy
    # turn on stats unix socket
    stats socket /var/run/haproxy.sock mode 600 level admin
    stats timeout 30s

    # increase max request size to support headers upto 24K (32k - 8k tune.maxrewrite)
    # as per docs: https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#tune.bufsize
    tune.bufsize 32768

    user haproxy
    group haproxy
    daemon
    nbproc 1

    # accept a larger number of connections (default=2000); this needs to be set in the frontend(s) also.
    maxconn 8000

    # Default SSL material locations
    crt-base /etc/haproxy/tls/pems/
    ssl-dh-param-file /etc/haproxy/tls/dhparams.pem

    # Default ciphers to use on SSL-enabled listening sockets.
    # For more information, see ciphers(1SSL).
    ssl-default-bind-ciphers TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
    ssl-default-bind-options no-sslv3 no-tlsv10 no-tlsv11

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    option  log-health-checks
    option  http-server-close
    option  forwardfor
    option  redispatch
    retries 3
    timeout http-request    5m
    timeout queue           1m
    timeout connect         20s
    timeout client          5m
    timeout server          5m

    # server defaults
    default-server check inter 10s fastinter 1s downinter 10s rise 5 fall 3 send-proxy-v2

    #errorfile 400 /etc/haproxy/errors/400.http
    #errorfile 403 /etc/haproxy/errors/403.http
    #errorfile 408 /etc/haproxy/errors/408.http
    #errorfile 500 /etc/haproxy/errors/500.http
    #errorfile 502 /etc/haproxy/errors/502.http
    #errorfile 503 /etc/haproxy/errors/503.http
    #errorfile 504 /etc/haproxy/errors/504.http

    stats enable
    stats show-node
    stats refresh 10s
    stats realm Haproxy\ Statistics
    stats uri /haproxy?stats
    stats auth haproxy:XX

#
# Cache
#
cache general-cache
    total-max-size 64
    max-age 300

#
# Frontends
#

# combined HTTP/HTTPS frontend
frontend http-https-vip
    bind 0.0.0.0:80
    bind 0.0.0.0:443 ssl crt /etc/haproxy/tls/pems/ alpn h2,http/1.1
    http-request add-header X-Forwarded-Proto http if !{ ssl_fc }
    http-request add-header X-Forwarded-Proto https if { ssl_fc }

    #http-response add-header X-HAProxy-Frontend http-https-vip

    # enable small-object caching
    http-request cache-use general-cache
    http-response cache-store general-cache

    # accept a larger number of connections (default=2000);
    maxconn 8000

    ## define ACLs to match HTTP requests URI/path
    ##
    acl path_beg_well_known_acme_challenge  path_beg /.well-known/acme-challenge/

    ## define ACLs to match HTTP request's Host: header

    ## host
    acl host_example    hdr(host) -i example.host    

    ## match ACL for LetsEncrypt path_beg_well_known_acme_challenge prior to matching for backend service
    use_backend letencrypt-pool if path_beg_well_known_acme_challenge

    ## match ACL for HTTP request's Host: header to backend
    use_backend example-pool if host_example
    

    ## use default backend if no ACL matched - this pool simply redirects to https://atech.host/
    default_backend default-pool

#
# Backends
#
backend default-pool
    redirect location https://site.com/

backend letencrypt-pool
    server letsencrypt 127.0.0.1:54321 no-check no-send-proxy-v2

## example
backend example-pool
    #http-response add-header X-HAProxy-Backend example-pool
    redirect scheme https if !{ ssl_fc }
    balance source
    server node-01 localhost:6081 weight 100 cookie 0
    option allbackups
    option  httpchk GET / HTTP/1.1\r\nHost:\ example.host\r\nUser-agent:\ HAProxy-Check
    
# end

Steps to reproduce the behavior

  1. In Chrome (vers 84.0.4147.105), make a request (http/2) to the affected site with Dev Tools enabled.

Actual behavior

  1. Some resources on the page load, or the initial page load, will result in net::ERR_HTTP2_PROTOCOL_ERROR 200, which is status code 200 in the Network tab, and response headers present, but no response body.
  2. In HAProxy access logs, the affect resource is shown as CD term state:
[05/Aug/2020:19:25:17.077] http-https-vip~ XX-pool/XX-01 0/0/0/6/6 200
16754 - - CD-- 1/1/0/0/0 0/0 "GET
/sites/default/files/js/js_b5CVpcMqsurBS2z_ljLBm79RgnowXJ_h8ce_XBlFrNg.js
HTTP/1.1"
  1. Result appears to be intermittent; subsequent retries of the URI may or may not repeart the error (with Dev Tools - Disable Cache enabled).

Expected behavior

Normally (haproxy 1.8.25, or haproxy 1.8.26 using http/1.1 proto) the requested URI would load without issue.

Do you have any idea what may have caused this?

No; but appears to be related to use of the http/2 protocol in haproxy 1.8.26. Disabling http/2 in the config resolves the issue.

Do you have an idea how to solve the issue?

No; see above.

OliverKellyATech avatar Aug 05 '20 10:08 OliverKellyATech

stats auth haproxy:*redacted*

Note: You appear to have posted a password there.

TimWolla avatar Aug 05 '20 10:08 TimWolla

Thankyou, removed.

OliverKellyATech avatar Aug 05 '20 10:08 OliverKellyATech

GitHub preserves old versions of the message and quite a few users will have received the initial message in their email inbox. You should not only remove the password, but also change it within your configuration.

TimWolla avatar Aug 05 '20 10:08 TimWolla

After commit~0ed8506 "BUG/MEDIUM: mux-h2: Emit an error if the response chunk formatting is incomplete", this problem seems to happen. This seems to break chunked transfer encoding!!

serimin avatar Aug 05 '20 11:08 serimin

Same issue after upgrade 1.8.26-1ppa1~bionic, disabling http/2 in the config resolves the issue.

cechevarne avatar Aug 05 '20 11:08 cechevarne

I guess this issue is related to https://github.com/haproxy/haproxy/issues/768#issuecomment-668752013. If yes, I'm on a fix.

capflam avatar Aug 05 '20 12:08 capflam

Wow.

h2spec did not catch it

chipitsine avatar Aug 05 '20 13:08 chipitsine

I pushed the fix in 2.0 and 1.8. Thanks !

capflam avatar Aug 05 '20 20:08 capflam

For completeness: this bug ony affects <= 2.0, and is therefor not in master. It's commit 307f31ec3 in 2.0 and 179d316c9 in 1.8 (BUG/MEDIUM: mux-h2: Don't fail if nothing is parsed for a legacy chunk response).

So we can close this.

lukastribus avatar Aug 05 '20 21:08 lukastribus