How redirect url request to a local VM

Discussions related to using VirtualBox on Windows hosts.
Post Reply
SpongeB0B
Posts: 6
Joined: 28. Jun 2019, 15:45

How redirect url request to a local VM

Post by SpongeB0B »

Hi everyone,

I have two Virtual Machine inside the computer A. I would like the outside people be able to reach website hosted on VM 1 and VM 2 depending of their respective URL Is there any possibility inside either the Host (windows 8.1) or VirtualBox to redirect the traffic according the URL?

I'm using a Dynamic DNS (VM1.DDNS.com and VM1.DDNS.com for exemple). If not possible did you know another alternative? (even if I have to put a machine between the router and the Host

Thank you :)
Attachments
2019-06-28-1455_VM.png
2019-06-28-1455_VM.png (15.68 KiB) Viewed 2779 times
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How redirect url request to a local VM

Post by scottgus1 »

I believe that if you have multiple websites behind a router, access to each website would require different ports through the router, one for each address. I think you'd have to set up your dynamic DNS provider to point your website names like this:

VM1.DDNS.com -> your.dyn.ip.address:8080
VM2.DDNS.com -> your.dyn.ip.address:8081

Port 80 is the usual port number for a website. When you enter a website in a browser, it defaults to asking for port 80. The above DNS setups will switch the requested website traffic to ports 8080 and 8081. 8080 is a common alternate port number for a website, the number could be any valid non-used port number. At least one of these will have to be an alternate, could be good to have them both be alternates.

Also, you set your guests to Bridged, so you have the guests on the same ip address range as your LAN. You can set static IP addresses in the guests to fit the LAN address scheme, like this, assuming a LAN ip address range 192.168.0.#:

both guests Bridged.
host ip address dynamic, set by DHCP (static is ok here, too)
VM1 ip static, 192.168.0.250, website on port 80
VM2 ip static, 192.168.0.251, website on port 80
both guests expect web traffic in their OS's port 80
(Substitute your LAN's ip address range for the 192.168.0 parts. It would be good to also restrict the range of addresses handed out by your router's DHCP server, so the static ip addresses won't be given to another device if your guests happen to be off one day.)

You should be able to access the VMs' websites on any computer in your LAN by typing 192.168.0.250 or 192.168.0.251 in a web browser.

In your router, set port forwarding rules:
traffic coming in on port 8080 to 192.168.0.250, port 80
traffic coming in on port 8081 to 192.168.0.251, port 80

When you type VM1.DDNS.com on a pc on the internet outside your LAN, your dynamic service will connect to your.dyn.ip.address:8080, your router will connect to 192.168.0.250:80, and you'll get your VM1 website. And so on...
SpongeB0B
Posts: 6
Joined: 28. Jun 2019, 15:45

Re: How redirect url request to a local VM

Post by SpongeB0B »

Thank you very much @ScottGus1 :!:

That a really efficient method ! (no resources consumption) I was as DDNS FreeMyIP did you know if I can set a port per subdomain as you suggest ?
or did you (or anyone) know a free DDNS who allow this ?

Thank you.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How redirect url request to a local VM

Post by scottgus1 »

I would not know myself if your DDNS provider would allow this or at least make you pay for it. I don't know if mine does, haven't ever needed to try such a setup. Might need to ask them.
Post Reply