I have setup haproxy in a lxd container and then on the host forward port 80 and 443 to container. I am using following commands for it:
/snap/bin/lxc config device add "{{container_name}}" http proxy listen=tcp:0.0.0.0:80 connect=tcp:127.0.0.1:80
/snap/bin/lxc config device add "{{container_name}}" http proxy listen=tcp:0.0.0.0:443 connect=tcp:127.0.0.1:443
When doing this haproxy logs show traffic coming from remote ip address 127.0.0.1 which is not right. I need the actual client ip, to be passed to haproxy even if its in X-Forward-For header.
Is it possible?
If its not possible what will be your suggestion?
The simple solution I can think of at present is to install haproxy from container to physical host.