How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine

Posted on

Introduction

This article is giving information on how to access Apache Webserver’s service. Actually, the service is a HTTP service running in a virtual server. The virtual server itself is running in a VirtualBox Manager. So, the access to the web page provided by a HTTP service from a Apache Webserver. The access is from a host machine. It will try to access the HTTP service in the guest machine. In order to accomplish it, adding a new rule for the port forwarding is one of the solution. It happens when the virtual server is running with an adapter with NAT type.

 

Adding HTTP Port Forwarding Rule

Below are steps to add HTTP port forwarding rule in a CentOS virtual server running in VirtualBox application  :

1. For the first step, just run the VirtualBox Manager. The following is the display of the VirtualBox Manager containing the virtual server :

How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine
How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine

The above VirtualBox Manager is a default display before there is a single virtual server available. When the virtual server is available, there will be an icon of that virtual server in the left side as in the next step.

2. So, in the following step, just select the suitable virtaul server in the VirtualBox Manager as exist in the following image :

How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine
How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine

3. Select the right virtual server and right click on it to get to the Settings Windows Dialog Box. The following image will appear :

How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine
How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine

4. Click the Port Forwarding button as in the above image, the following image of the Setting Window Dialog Box will appear :

How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine
How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine

5.  Finally, add a new rule for forwarding incoming request from a port in the Host Machine. It will redirected to a port in the Guest Machine. Port Forwarding is just an utility to be able to access a service available in the CentOS virtual server. Click the Plus Sign, the following image will appear :

How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine
How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine

6. Configure the entry Port Forwarding in the new added line as in the above image as follows :

How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine
How to Add HTTP Port Forwarding Rule to access Apache Webserver of Guest Machine running in VirtualBox Manager from Host Machine

The important rule exist in the last line or the second line. The above definition means that every connection that come from port 9980 in the local host where the VirtualBox application run will be redirected to the Virtual Server IP Address of 10.0.2.15 in port 80. Basically, it will access any service run in port 80. Since Apache Webserver by default is running in port 80, it will display a default web page in the browser.  The host machine port is using 9980 just for an example.

Leave a Reply