[Lxc-users] Redirect localhost requests to a Linux container

Robin Monjo robin.monjo at applidget.com
Wed Jul 31 09:01:09 UTC 2013


Hello, I'm struggling with port forwarding for requests coming from localhost.

I run some linux container on my ubuntu host. Each one of them are running a webapp. To be able to access these webapps, I use iptables to forward port:

sudo iptables -t nat -A PREROUTING -p tcp --dport <port> -j DNAT --to-destination #<container_ip>:<port>
This work well if the traffic comes from outside of my machine. If the request is done by localhost it doesn't work:

  curl <host_ip>:<port> #works (from outside the host)
 curl <container_ip>:<port>  #works (from inside the host)
 curl 127.0.0.1:<port>       #doesn't work (from inside the host)

Any clue how to be able to make this last curl command working ?

Regards,
Robin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20130731/467e3d01/attachment.html>


More information about the lxc-users mailing list