I have been trying for some days and still have no luck with getting transparent TCP load balancer to work using HAproxy/NGINX.

The problem is: everything works correctly, until i try to enable transparency. Both NGINX and HAproxy do load balance, but give localhost as user IP.

What i tried to change this:

So, the general question is: i have HAproxy/NGINX load balancing on x.x.x.x:30000. On the same machine, i have apps at x.x.x.x:30001 and x.x.x.x:30002.

How can i load balance this configuration? Which additional routing rules are required? Do i need to create a virtual subnet for some rerouting? Because as of now it seems like load balancer can connect to the app, but can't get the answer back to the user.


1 Answer 1


I'm not sure you can do it on the same host.

TPROXY is complicated at the best of times. I've only ever seen it working well with two seperate subnets AND seperate hosts (virtual or physical).

Are you sure that you cant just use something simpler like DSR mode?

I know LVS DSR works on the same host.

Or what about HAPROXY PROXY PROTOCOL (if you app supports it).

In theory I guess TPROXY should be possible on a single host, so maye someone clever will answer :-).

  • Thanks for the answer. I contacted HAproxy support and they told me something similar, it seems at least 2 NICs are required, with one acting as input for the proxy, being the gateway of backend. In the end i had to use proxy protocol, because it turned out to be much easier. It's a miracle my app supports it, though :)
    – NIK220V
    May 17, 2020 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .