I’m following these tutorials to host multiple websites in a VM:
In these tutorials, they are using HAProxy and iptables to redirect traffic from port 80 to each container. My first thought was to do the same with port 22, but I was afraid that by doing that I would lock myself out of my VM, so I went to my container (which I have a website) and changed ssh_config file to listen to port 25000.
After that in the host, I set some iptable rules:
sudo iptables -t nat -I PREROUTING -i ens3 -p TCP -d HOST_IP_ADDRESS/32 --dport 25000 -j DNAT --to-destination CONTAINER_IP_ADDRESS:25000
I also edited /etc/haproxy/haproxy.cfg to:
Doing that, I can access via SSH if I’m inside host, but not from outside. Is it possible to access each container invidually via SSH? Could someone help me to solve this?
I’m using Ubuntu 18.10 and LXD version is 3.6.