These steps are my understanding of LXC/LXD containers at the time they were created. I am still learning. (Here there be dragons.)
This will be the host (server) for the containers.
Note:
UFW is a simplified interface to iptables.
After installation enable it, if it isn't already.
Note: I don't know which ports "lxc launch" (and other steps) require open so I temporarily open them all.
Note: At the time of these steps 24.04 is the latest ubuntu LTS distribution. If there is a newer one use it.
You should see the HTML for the home page. This verifies the web server is working and is available from the host.
This command will allow port 80 and potentially port 443 if the application profile for "www" includes it.
Connect the container to the external world.
Expose a container port to the host with a proxy. My LXC/LXD Proxy InformationSince ufw 0.34 ufw supports forward rules.
Example
You also need to make sure you have the sysctl net.ipv4.ip_forward enabled. For most distributions, that's done by editing /etc/sysctl.conf and running sysctl -p or rebooting.
Note: UFW does not support NAT through its easy interface.
serverfault.com/questions/238563/can-i-use-ufw-to-setup-a-port-forward
How to configure UFW to allow IP Forwarding?
Are there other methods? What about multiple independent web servers (containers) on a single host? What about DHCP? Routable vs non-routable IP address? What about NAT?
Start adding web pages to the server. The root folder
(directory) is "/var/www/html/".
(
HTML Tutorial )
ifconfig (Wikipedia)
In a Linux system, "eno1" is a naming convention for the first onboard Ethernet network interface card (NIC). It signifies that the network adapter is integrated directly into the computer's motherboard and is the first such device recognized by the system.Note: eth0, eth1, ... were traditionally the names used for Ethernet interfaces, but modern systems often use predictable naming schemes like "eno1" for better consistency.
An LXC bridge network allows Linux containers (LXC) to communicate with each other and with the host machine as if they were on the same physical network segment. It effectively creates a virtual switch, enabling direct communication between containers and the host, similar to how virtual machines or physical devices on a network interact.
Building a Network of Websites/Web Servers With LXD, for Beginners
How to Configure Bridge Networking in LXD
How to configure LXD network to host bridge?
LXC Container on same network as host with internet access
Apache HTTP Server (Wikipedia)
How to configure ufw to forward port 80/443 to internal server hosted on LAN
lxc container assigned ip address by external dhcp server
UFW (Ubuntu - Community Help Wiki)
Configure Networking for LXD Virtual Machines on Ubuntu Linux (YouTube)
Configure Networking for LXD Virtual Machines on Ubuntu Linux
(YouTube)