Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Ok, here's what I want to do: I want to connect to a webserver running on a virtual machine.

I have an Apache webserver running on my host machine: Windows Vista, which can be accessed from the web.

I have VirtualBox running a guest machine: Ubuntu which also has an Apache webserver and I want to be able to access both servers from the web.

I've been searching and searching trying to find out how to do this and I couldn't find any step-by-step instructions on how to set it up.

It looks like reverse proxy will accomplish what I want, but I'm not sure how to set that up either.

Thanks for the help in advance!

share|improve this question

4 Answers 4

Another option is to use the Apache running on your host OS as a proxy for the Apache running on your guest OS. I think it's called mod_proxy.

share|improve this answer

You can't have two different things answer on the same port (i.e.: 80 for WWW) on the same IP address.

So you need to either change one of the web servers to asnwer on a different port (say 81), and then forward that port in your router to the 2nd web server.

Also, if your router is smart enough, you can set it up to answer on the custom port (81) and have it forward to the 2nd web server on port 80 (therefore keeping the webserver configuration on the standard port 80 for internal testing/use).

Either way, from the Internet you would then access web server 1 on the standard port 80 (http://www.servername.com) and the second via the other port (http://www.servername.com:81).

share|improve this answer

I've been doing this with a CentOs server on my VirtualBox

You will need to set the Virtual Machines network as a Bridged Adapter and choose the network adapter that you use network connections for.

Go into your Ubuntu box and it should automatically be assigned an address from DHCP, if not then you will need to set a static IP Address manually in Administration > Network.

Once you have your address, you can check for it using ifconfig then it will return a list of your network interfaces. Look out for eth0 and it's IP Address.

Take a note of this and enter it into your Vista OS' web browsers address bar, the Apache Screen should be showing, or whatever you have used in your www directory.

EDIT:

Since you are using port 80 already and that port is forwarded, what you can do is set the port on the Ubuntu Server to a different one, possibly 8080. Edit your configiration file which may be located at /etc/apache2/apche2.conf.

Then edit the Listen 80 to Listen 8080 and restart apache /etc/init.d/apach2 restart You will then be able to see your Ubuntu installations server at ubuntuhostip:8080

Then simply create a new service in your routers firewall with the start port as 8080 and the end port as 8080 and then set the firewall rules but with the ubuntu ip address set on the 8080 service port.

This way you can access:

Vista Server: mainip

Ubuntu Server: mainip:8080

share|improve this answer
    
Thanks for the reply. I have VBox setup with bridged adapter. I can access the ubuntu webserver from my host browser, however I want to access the guest ubuntu webserver from the web, ie outside my local network. How can I set it up to do this? Step-by-step instructions please. –  jspike Apr 20 '11 at 20:03
    
What Router do you have, it normally helps –  Sandeep Bansal Apr 20 '11 at 20:06
    
I have a LinkSys router. I have the router configured to forward port 80 to my host computer. So I can access the webserver running on the host machine from the web. –  jspike Apr 20 '11 at 20:25
    
Edited my answer to explain port forwarding to a different port for multiple web servers –  Sandeep Bansal Apr 20 '11 at 20:30
    
Alright, I've been working on this for a while now and still can't get it to work, I must be missing something. If guest listens on port 80, I can access it from the host, if guest listens on any other port, I can't access it from the host, much less the web. Why can't I access guest from another port? I've been trying to use 8080. –  jspike Apr 21 '11 at 3:31

There are a few different virtual networking modes.

I recommend you use either Bridged networking when it comes to what you want.

If you choose NAT, you have to configure port forwarding on your host machine in the same way as you do on your router.

If you follow my advice and choose bridged, then, any virtual machine will appear to your network as a physical independent computer. All you need to do is find the IP of your virtual machine (or set it as static), then port forward the web server in the same way as you would any other machine from your router.

share|improve this answer
1  
Thanks for the reply Wil. I have VBox setup with bridged adapter. I can access the ubuntu webserver from my host browser, however I want to access the guest ubuntu webserver from the web, ie outside my local network. How can I set it up to do this? Step-by-step instructions please. –  jspike Apr 20 '11 at 20:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.