0

i have 4 VM's in VirtualBox on an Ubuntu 17.04 desktop computer, which is connected to a MAAS subnet.

each VM is configured with Apache and OpenSSH, for one of 4 domains i have.

my problem is that i only have one 80 port and one 22 port on my router, and i want to forward the ports to the right VM by the requesting domain; for example:

ssh user@domain1.com -> domain1.com_VM

ssh user@domain2.com -> domain2.com_VM

thanks in advance

Nadav Tasher
  • 109
  • 1
  • Your questions could be improved a lot by using a proper grammar, chat style isn't very popular here. – peterh Jul 28 '17 at 00:18

1 Answers1

1

This is possible for HTTP port 80 as the HTTP/1.1 protocol has Host: header for identifying the hostname i.e. domain. You'd need to have a reverse proxy that handles all the connections and uses the correct VM as a back-end server, based on the Host: header. If your router can't work as one, you could utilize one VM for that and port forward 80 to it.

For SSH port 22 you simply can't do the same, because the protocol doesn't have a way to mediate the hostname used for the connection: after resolving correct IP from the DNS only the IP address is used for the connection.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122