HAProxy with backend requiring Proxy-Authorization suddenly not working anymore

Hello there,
I use HAProxy to load-balance (and to use active and backup servers) between multiple HTTP proxies (all of which require Proxy-Authorization).
Until yesterday, the following config worked flawlessly:

frontend local
        bind 127.0.0.1:8118
        mode http

        default_backend main

backend main
        balance leastconn
        http-reuse always
        http-request set-header Proxy-Authorization Basic\ <base64 user:pass>
        http-request set-header Proxy-Connection Keep-Alive
        server 1 <ip:port> check fall 3 rise 3 inter 15s   observe layer7 error-limit 10 on-error mark-down

The rest of the config is default from Debian 12 package.

This worked until yesterday but has broken all of a sudden:

HTTP/1.0 407 Proxy Authentication Required
proxy-authenticate: Basic realm="proxy"
< content-type: text/html; charset=utf-8
< 
* CONNECT tunnel failed, response 407

I made sure via curl that all proxy servers are still working, i.e.:

curl -I -v -x <ip:port> --proxy-user <user:pass> http://www.google.com

which returns HTTP/1.1 200 OK.

But HAProxy is just not working. Not anymore. Nothing changed. I am at a loss…
Any advice?

can you check if your server1 is active and you are able to connect to it from haproxy server/pod ?

I actually have 5 servers in total, 3 of them are active, 2 of them are marked as backup, all of them are up. However, when I try to curl the local frontend, i.e.:

curl -v -x 127.0.0.1:8118 https://www.google.com

I get:

*   Trying 127.0.0.1:8118...
* Connected to 127.0.0.1 (127.0.0.1) port 8118 (#0)
* allocate connect buffer
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.88.1
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.0 407 Proxy Authentication Required
< proxy-authenticate: Basic realm="proxy"
< content-type: text/html; charset=utf-8
< 
* CONNECT tunnel failed, response 407
* Closing connection 0
curl: (56) CONNECT tunnel failed, response 407

which is weird since my HAProxy specifically sets the Proxy Authentication http header and it has worked for the past 2 months without any problems.

When I use curl with one of the proxy servers directly, i.e.:

curl -v -x <server_1_ip:port> --proxy-user <user:pass> http://www.google.com

it works perfectly.

So for some reason, setting the http-request header in HAProxy, i.e.:

http-request set-header Proxy-Authorization Basic\ <base64 user:pass>

has stopped working.

I dunno what I can do to make HAProxy work with external proxies that require that auth again…
Like I said, my working (for two months) config just stopped working even tho nothing changed…

It’s getting weirder.
I just fired 20 of those cURLs using the local frontend and two of them actually worked and didn’t throw the 407 error.
What the F is happening?

HAProxy log for one of the successfull requests:

local main/1 0/0/30/33/331 200 28862 - - ---- 1/1/0/0/0 0/0 "CONNECT www.google.com:443 HTTP/1.1"

So IT IS WORKING. but why is is so unbelievably unreliable?

When I cURL the proxies directly, none fail.
When I set the proxies as HTTP proxies in Firefox, it works.
But when I try to use them as servers in HAProxy backend, it’s suddenly super unreliable.

Any ideas anyone?

Found this which seems related to my problem: