Hey guys,
I have an fresh install of:
Ubuntu Server 20.04 Host (10.0.1.0/24)
LXD 4 (Ubuntu 20.04 conteiners) (10.177.0./24)
NGINX (Host and inside conteiners)
The goal is have one conteiner per domain.
While testing I got 3 conteiners.
On Host my NIC is ens160 (ESXI Server) and have multiple IPs (10.0.1.20/24 - 10.0.1.21/24 - 10.0.1.22/24 - 10.0.1.23/24 - wich will be one per domain).
On NGINX at host I use the stream option to forward SSH calls to conteiners, and proxy to access the webservers inside the conteiners.
Example /etc/nginx/streams.conf:
stream {
server {
listen 10.0.1.121:121;
proxy_pass 10.177.0.21:22;
}
server {
listen 10.0.1.122:131;
proxy_pass 10.177.0.22:22;
}
server {
listen 10.0.1.123:132;
proxy_pass 10.177.0.23:22;
}
}
This works fine without IPTables enable.
For proxy, every domain at Host using Nginx its similar to:
location / {
allow all;
proxy_pass https://10.177.0.121;
}
From LXD install I have used:
Would you like to use LXD clustering? (yes/no) [default=no]: no
Do you want to configure a new storage pool? (yes/no) [default=yes]: yes
Name of the new storage pool [default=default]: default
Name of the storage backend to use (btrfs, dir, lvm, zfs) [default=btrfs]: btrfs
Would you like to create a new btrfs dataset under rpool/lxd? (yes/no) [default=yes]: no
Create a new BTRFS pool? (yes/no) [default=yes]: no
Name of the existing BTRFS pool or dataset: /lxd
Would you like to connect to a MAAS server? (yes/no) [default=no]: no
Would you like to create a new local network bridge? (yes/no) [default=yes]: yes
What should the new bridge be called? [default=lxdbr0]: lxdbr0
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 10.177.0.1/24
Would you like LXD to NAT IPv4 traffic on your bridge? [default=yes]: yes
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: none
Would you like LXD to be available over the network? (yes/no) [default=no]: no
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] yes
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: yes
With this basic setup, everything works fine.
Now when I try use Iptables, haven’t found an way to keep this working.
I have read a lot of posts here abour PREROUTING, FORWARD DNAT and seems none of the suggestions work in my specific scenario.
I’m searching at google too, but without success.
Someone would point me what I need do to get it working with Iptables? Or if not possible with my current scenario.