We have LXD 3.0.1 installed on an Ubuntu 18.04LTS virtual machine. For the sake of this explanation, I have created two Debian 9 containers for doing development in Ruby on Rails. I have set up the first to use macvlan so that it acquires an IP address from the network DHCP server (we’ll call it ‘c1’). I have set up the second to use the default bridged mode so that it acquires an IP address directly from the LXD host (we’ll call it ‘c2’).
To c2, I added the following proxy devices to port forward from the LXD host to the LXC container:
lxc config device add c2 port22 proxy listen=tcp:0.0.0.0:2000 connect=tcp:localhost:22
lxc config device add c2 port80 proxy listen=tcp:0.0.0.0:2001 connect=tcp:localhost:80
lxc config device add c2 port3750 proxy listen=tcp:0.0.0.0:2002 connect=tcp:localhost:3750
where 22 is for SSH’ing into the container, 80 is for the Nginx webserver installed on the container, and 3750 is the Rails server port I use when doing development of code on the container.
If I’m SSH’d onto c1 (the one with the network granted DHCP address) and I spin up my Rails server …
rails s -p 3750 -b 0.0.0.0
and open up Firefox and direct the URL to http://ip-address-to-container:3750, the pages load fine.
However, on c2, when I spin up the same server on local port 3750 and then try to access them via the LXD host and the port I mapped (http://ip-address-to-lxd-host:2002), the page loads, but the container never appears to send a close connection signal. Thus, in Firefox, the spinning balls that indicate that the browser is still waiting continue to spin. Even if I terminate the local Rails server (ctrl-c), the local process stops in the container, but Firefox still indicates it is waiting.
To further complicate matters, if on c2 I serve the very same project using Nginx (on port 80), and connect via http://ip-address-to-lxd-host:2001, the page loads fine and terminates the connection upon loading the page, as expected.
My questions are:
- Have I configured c2 incorrectly? Is there something I need to add to the port forwarding config device command?
- Is there something about port 80 versus 3750 (perhaps privileged port vs. unprivileged?) that makes one terminate connections upon completion vs. not?
Thanks for any help; sorry for the long explanation.
Edit: Formatting issues.