That doesn’t work in tunnel mode (only the first request will have the IP).
In Squid >= 3.5 you could use the PROXY protocol, this would solve your issue.
Otherwise go back to keep-alive mode, but use a high “timeout http-keep-alive” setting, like a few minutes. That should improve the situation (but NTLM is and always will be a mess).
Yes, my Squid is 3.5, but how works the PROXY Protocol? Do you have a example of configuration in squid.conf that fix this issue and show the real ip? The Proxy protocol is in Squid side or Haproxy side?
I try this in haproxy.cfg:
server squid126 172.19.0.126:3128 check send-proxy
and
server squid126 172.19.0.126:3128 check send-proxy-v2
but doesn’t work … the internet on client don’t work …
I quickly searched through squid documentation. If I understand correctly, for x-forwarded-for to work, you currently specify the follow_x_forwarded_for directive, allowing the haproxy IP. You would need to do the same by using the proxy_protocol_access directive:
In haproxy I put:
server squid126 172.19.0.126:3128 check send-proxy
In Squid.conf I put:
acl haproxyip src 172.19.0.121
proxy_protocol_access allow haproxyip
http_port 172.19.0.126:3128 require-proxy-header
via on
follow_x_forwarded_for allow all # Necessario para passar o IP do Cliente no haproxy
request_header_access X-Forwarded-For allow all
request_header_access Allow allow all
forwarded_for on
This is probably a security issue. Everybody can specify any IP Address in x-forwarded-for and squid will log that one. Now that you are using PROXY, you can remove this option altogether. If you would still be using x-forwarded-for, you would have to set this to the haproxy IP, instead of “allow all” for that reason.
When I’m logged on domain (therefore NTLM) the Internet is work fine … but when I access on PC that is not logged in domain (therefore not NTLM) the access is denied, and the internet doesn’t work …
It seems that haproxy does not pass the user and password to squid with the proxy protocol enabled. With the proxy protocol enabled the machines logged in the domain work well, but those that are not in the domain, is asking for the authentication screen all the time.
@gianfcn I have the same problem with the same settings, but in my case, I have two diferents clusters, with the same settings. In our enviroment with squid 3.5.13 and haproxy 1.5.18 works fine, but in the other enviroment with squid 3-5.25 and haproxy 1.5.18, the NTLM authentication only works if at first you request a https URL.