When defining a new proxy device to connect a host IP:port to a container, What is the difference between using 127.0.0.1 vs the actual IP of the container?
The proxy switches into the container’s namespace before trying to connect to the service, you are able to use 127.0.0.1 respective of which container you are connecting to (assuming the service listening on 127.0.0.1 inside the container.
All you need to do is replace the container name and proxy name.
This command adds a proxy device named proxy-name to the specified container, listening on all interfaces (0.0.0.0) on port 80 of the host, and forwarding to the container's port 80 on the loopback interface (127.0.0.1).
After adding a proxy, traffic hitting port 80 on the host machine will be forwarded to the container's port 80. This is a common way to expose web or other services running inside LXD containers to the outside world.
Congrats, the web server can now be accessed using the container host's IP address and port 80.