virtualbox view guest port 80 on host port 80
So i'm trying to forward the guest port 80 to my host port 80 so that I can view the apache running on my guest in my host's browser.
If I set the following: (8080/80), I can view localhost:8080 and see the guest apache server.
When I set host to 80 and guest to 80, it doesn't work. How would I get guest 80 to direct to host 80?
Assume running in NAT mode is mandatory.
From your screenshot, it appears that you are running VirtualBox on OS X - is that correct?
If so, by default - a user account can not create IP endpoints that listen on ports below 1024. You are left with two choices if you absolutely need to have something listening on a low port number:
- You can run VirtualBox as root (or other privileged account) - but this not a recommended solution as it tends to bypass a lot of the security restrictions.
-
You can add a forwarding rule to your firewall, say from port 8080 to 80, to silently redirect the traffic for you. Your VirtualBox would still be configured to forward port 8080. In a nutshell:
- Open a Terminal, and type
sudo vi /etc/ipfilter/ipfw.conf
- Add this line:
add 12001 fwd 127.0.0.1,8080 tcp from any to me dst-port 80
- Save and close the file:
:wq
- Open a Terminal, and type
Disclaimer: I don't have a Mac in front of me, let alone a recent copy of OS X - so while the high-level ideas still apply, the actual details of configuring the firewall forwarding rules may be slightly different depending on which version you are currently running.
There may be better ways still to handle this. For example, if you configure a second virtual adapter for your guest and configure it as "Host-Only" you can then access any of the ports on the guest from your host without having to forward any of the ports. This may not make sense if you need to share the guest across your network - in which case perhaps the "Bridged" virtual adapter would make more sense. I would suggest reading up on the different networking modes in Chapter 6 of the VirtualBox Manual: https://www.virtualbox.org/manual/ch06.html