Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to rotate between a few http authenticated proxies. But I am unable to plug this into the config file because the url structure is different. It works when i remove the username and pass (but requesting the username and pass of course). Is there a way to send the credentials? If i don't add them i am getting a 407 proxy auth error.

        maxconn 500

        mode http
        timeout connect 5000ms
        timeout client 50000ms
        timeout         server 50000ms

frontend rotatingproxies
        bind *:3000
        default_backend rotateproxy
        option http_proxy
        option http-use-proxy-header

backend rotateproxy
        option http_proxy 
        server proxyserver
        server proxyserver

        balance roundrobin
share|improve this question
up vote 3 down vote accepted

It does not work this way. You need real server address. If you want to add a user-name and password, there is a solution. You need to first encode them in base64 by hand and add the resulting string in the Proxy-Authorization header. For instance :

$ echo -n user:pass | openssl enc -a

backend rotateproxy
   server proxy1 ip1:9999
   server proxy2 ip2:9999
   reqadd Proxy-Authorization:\ Basic\ dXNlcjpwYXNz

Your client will have to use haproxy as an explicit proxy however, and you need to remove "option http_proxy".

share|improve this answer
Works perfectly. Thanks! – Vinoth Gopi May 10 '12 at 7:23
This answer doesn't work for redirects since HAProxy passes headers during the first request of a TCP session only. The solution is to pass the credentials as part of the balancer url: HTTP_PROXY=http://username:password@localhost:3000. For more details see – gsakkis Mar 10 '15 at 14:43

I searched through the HAProxy-1.3 documentation, and it does not seem to support what you are asking for.

If you have access to the backend server, I would suggest turning authentication off there, and adding another web-server, e.g. nginx, in front of HAProxy to only do basic http authentication.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.