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

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


Ok, within the container it's listening on all interfaces (including lo) :

tcp        0      0 0.0.0.0:3100            0.0.0.0:*               LISTEN

So within the container I can curl 127.0.0.1:<port>

However the host is not listening but that seems normal to me. The goal is to redirect packet from HOST 127.0.0.1:<port> to <container_ip>:<port>

On Jul 31, 2013, at 11:24 AM, Shibashish <shib4u at gmail.com> wrote:

> Thats what my query is... how do u make sure? Your service seems to be LISTENing on ethX, but not on "localhost". You can access it from outside means it is listening on your ethX interface.
> 
> e.g. my smtp is listening on localhost
> 
> [root at myhost ~]# netstat -an | grep 127.0.0.1
> tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN
> 
> 
> ShiB.
> while ( ! ( succeed = try() ) );
> 
> 
> On Wed, Jul 31, 2013 at 2:48 PM, Robin Monjo <robin.monjo at applidget.com> wrote:
> Yes absolutely sure since I can access it from the outside
> 
> On Jul 31, 2013, at 11:15 AM, Shibashish <shib4u at gmail.com> wrote:
> 
>> Are you sure your service is listening on localhost:<port> ?
>> 
>> I'd use "netstat" to verify that first.
>> 
>> ShiB.
>> while ( ! ( succeed = try() ) );
>> 
>> 
>> On Wed, Jul 31, 2013 at 2:31 PM, Robin Monjo <robin.monjo at applidget.com> wrote:
>> 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
>> 
>> ------------------------------------------------------------------------------
>> Get your SQL database under version control now!
>> Version control is standard for application code, but databases havent
>> caught up. So what steps can you take to put your SQL databases under
>> version control? Why should you start doing it? Read more to find out.
>> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Lxc-users mailing list
>> Lxc-users at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/lxc-users
>> 
>> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20130731/952f962c/attachment.html>


More information about the lxc-users mailing list