I figured out the solution after much headbanging (although I figured it out some while ago, replying a bit late).
The solution is to use NAT technique with port forwarding. All you have to do is, in the network setting of the vms in VirtualBox add Port Forwarding rules. There are no restriction on the value of the ports and they could be anything as long as there are no conflicting ports and it is advisable not to use certain port numbers.
For setting the rules: Host IP is the IP of your main machine and Guest IP is the NAT IP of the VM. Any request coming to your host on that port would directly be redirected to the guest ip on the port you have mentioned.
Here the first IP refers to my host machine, i.e. the one on which the VirtualBox is installed. And the second IP refers to the guest machine, i.e. the one which I need to start the server or connect to.
Because the service is not accessible when the virtual nic is in either bridged mode, or is in NAT mode with a correctly configured forward rule, the issue is likely to be with the guest server, or the service itself.
Many services are not configured to accept remote connections by default, and open network ports for listening on the loop back network interface only. To determine what interface your service is bound to, use this command:
Linux:
# netstat -ntlup | grep portnumber
windows:
netstat -abno | FINDSTR LISTENING
and make note of the IP address the port/process is bound to.
# netstat -ntlup | grep 53
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 835/dnsmasq
udp 0 0 127.0.1.1:53 0.0.0.0:* 835/dnsmasq
shows the dnsmasq service running on the loopback interface (127.0.x.y), and can only be accessed by processes running on the localhost.
# netstat -ntlup | grep 445
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 566/smbd
tcp6 0 0 :::445 :::* LISTEN 566/smbd
However shows the service listening on ALL interfaces (0.0.0.0).
finally,
# netstat -ntlup | grep 138
udp 0 0 10.0.2.255:138 0.0.0.0:* 960/nmbd
udp 0 0 10.0.2.15:138 0.0.0.0:* 960/nmbd
shows the service listening on eth0 (host IP), and any broadcasts received on eth0 (host network broadcast address ending in .255) since Samba protocols use IP broadcasts.
Each service has its own means of enabling remote connections. this is somthing that must be configured in the service itself (no OS level control), because when the service opens the port for listening, it specifies the details of what interface to bind to. Usually (in linux) it involves specifying the interface binding in the services main configuration file, and restarting the service. In Windows, you are more likely to find a checkbox saying "allow remote connections" or some such, but you usually still have to restart the service for the change to take effect.
Best Answer
You don't need to NAT a connection outgoing from the guest to the host.
Make sure that the proxy configuration is such that it permits connections from the IP address range the virtual host is using, then all you need to do is configure the host IP and proxy port in the virtual host proxy config.