Multiple proxy protocol headers

I’m trying to setup a simple multi-layered haproxy setup to mimic a real-world issue with some devices with each proxy adding a proxy protocol header to the first packet as it goes through.

However, I’ve been quite unsuccessful trying to mimic that. The second proxy receives the packet with a proxy header but as it sends out its own header, it strips out the old header. Is there a way one can persist both the headers when the packet reaches the backend?

These are my config.

This is for proxy1. This receives the request from the client and proxies it to another proxy.

global
defaults
        timeout client          30s
        timeout server          30s
        timeout connect         30s

frontend MyFrontend
        bind                    0.0.0.0:80
        default_backend         TransparentBack_http

backend TransparentBack_http
        mode                    http
        server                  Proxy 172.18.0.3:80 check send-proxy

This is for proxy2. This handles the connection from proxy1 and sends it to the server.

global
defaults
        timeout client          30s
        timeout server          30s
        timeout connect         30s

frontend MyFrontend
        bind                    0.0.0.0:80
        default_backend         TransparentBack_http

backend TransparentBack_http
        mode                    http
        server                  WebServer 172.18.0.2:80 check send-proxy-v2

Not in HTTP mode. Because a TCP payload that begins with a proxy header by definition is not HTTP.

So, if you want to pile up proxy headers for a particular reason, you need to switch to mode tcp and also you need to remove accept-proxy everywhere, because accept-proxy will read and remove the proxy-header.