[Lxc-users] Redirect localhost requests to a Linux container
Aamir Ahmad
aamir.mushtaq.mailing at gmail.com
Thu Aug 8 06:43:51 UTC 2013
Hi, It seems what you want to achieve can be done using ssh's local
port forwarding option set on host machine.
I see you have made use of Iptables PREROUTING. Iptables PREROUTING is
similar to ssh's port forwarding. Can you try out the ssh (-L) option
and tell me if you had any progress.
For reference to usage of the ssh -L option, you can refer to the
"Local Port Forwarding" section in the link:
https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding#Local
Port Forwarding
A concern regarding use of NAT, NAT wont allow you to access the
container IP's outside the host. This is one of the reasons why i use
Bridged network together with an internal network to setup my
containers.
Regards,
Aamir Ahmad
NTT DATA
On Wed, Jul 31, 2013 at 3:00 PM, Robin Monjo <robin.monjo at applidget.com> wrote:
> 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
>>>
>>
>>
>
>
>
> ------------------------------------------------------------------------------
> 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
>
More information about the lxc-users
mailing list