LXD Proxies Instead of Bridging or Macvlan

Normally I like to present ways to expose LXD containers on your LAN via either bridging or macvlan. If you would rather not have a new LAN address for your LXD containers, you can just create the container and by default it will have a NAT address internal to your LXD host. In this video, I show how to expose ports from NATed containers to your LAN using proxies.

Create a simple LXD container.

lxc launch ubuntu:22.04 test1 --profile default -c boot.autostart=true

Create a proxy for port 80 which will expose that port to the LXD host address at port 8080.

lxc profile create proxy-8080
lxc profile device add proxy-8080 hostport8080 proxy connect="tcp:" listen="tcp:"
lxc profile show proxy-8080

Add the proxy to the container we created above:

lxc profile add test1 proxy-8080

Enter the container from your lxd host:

lxc exec test1 bash

Update the repositories and install the Apache web server as a test:

apt update
apt install apache2 -y

Go to your web brower at port 8080 and you will see that apache has been proxied to that port. For example, in my case: