My backend application is running behind the traefik which acts as an main load balancer. for our use case our requst should be end to end encrypted so we enabled ssl pass through in traefik level and use tcp router for 443.below shows our configuration for reference. (we are running in AWS ECS)
If you don’t get ProxyProtocol to work, you can try a different approach. Don’t use TLS passthrough, but terminate TLS at Traefik, then use new TLS to proxy/forward to a https target service. Then Traefik should add regular http headers like X-Forwarded-For or X-Real-Ip.
The TCP packets are routed by the load balancer, so the IP addresses will change. There are only two ways to preserve the original IP:
Use ProxyProtocol to wrap full traffic in a special stream, prefix with source IP
Use HTTP headers, which requires to decrypt requests and then encrypt again
I tested the internal ProxyProtocol connection from Traefik to a target service proxyprotocol client and it works for me. You can "tunnel" an encrypted TLS request through Traefik (without decrypting) and still see the original source IP in the target service:
If you want end-to-end encryption and the Traefik load balancer has no access to the certs, then you can only use a tcp router without any TLS active, with HostSNI(`*`). This enables only a single service per port, as Traefik can not read host or path from request.
our behaviour is our application will handle n no of user and each individual user has different ssl (1600 approx) that are maintained by our backend nginx level. and so we cannot able to set that ssl and cannot mention specific domain in the load balancer level here (traefik). so we moved to go for tcp router which will pass through the tls without need of placing the ssl cert for the n domains.
from the above scnerio traefik is working fine to the core but , one thing is we cannot able to get the client ip at the backend beceause of tcp router, instead we are getting traefik ip . we need client ip this is the case we need to achieve .
if we set the "traefik.tcp.services.agm-service.loadbalancer.proxyprotocol.version": "2" in labels we get the below error in nginx.