Centos – Accessing a web server behind router, when port forwarding is not an option. Like localtunnel but for multiple sites

apache-2.2centosport-forwardingssh-tunnel

The situation
I'm running a web server (CentOS on VMware, multiple virtualhosts) on a development machine and I'd like to give access to clients to view some sites without me having to upload them to an external hosting account.

The problem
I don't have access to the router, and so can't set up port forwarding. I do however, have a hosting account (with ssh access) and even a VPS.

The question
Is there something I could set up on my external hosting account or VPS that would handle web page requests by somehow pulling the data from my local server (behind the router) and serving it to the end user? I understand it's a bit convoluted, but performance doesn't really matter.

Thank you!!!

Best Answer

There are already good ideas, but here is the solution to make your VMWare accessible as if it was on your vps:

  1. Install openvpn server on your vps. There are many tutorials. I suggest choosing the bridged mode ( with the tap interface ). Choose an ip range like 10.1.2.1-254 ( 10.1.2.0/24 ). Once you have generated your ca etc, generate a client key called "vmware", without a passphrase, and in the /etcopenvpn/cdd directory put a file called "vmware" with this content:

    --ifconfig-push 10.1.2.3 255.255.255.0

the important lines in your server.conf (ie: which you have to change from the default config)

dev tap0
server-bridge 10.1.2.1 255.255.255.0 10.1.2.100 10.1.2.110
client-config-dir /etc/openvpn/ccd

Make sure udp port 1194 is open for public access ( or at least from the public ip of your vmware machine ).

  • On your vmware install also openvpn, but in /etc/openvpn/ directory you put:
  • your private key + certificate + ca certificate
  • a file named "vps.conf" with the client configuration

important lines:

remote <public ip address your vps> 1194
ca, cert, key

If you enable the openvpn service ( checkconfig openvpn on ) the client will start automatically at boot, establishing a tunnel between your vpn and your vps.

  1. Now in the apache configuration of your vps create a vhost ( not the default one preferably ) with something like:

ServerName MyVmware.vm.ware.com

RewriteEngine On RewriteRule (.*) http://10.1.2.3/$1 [P,L]

Here you are..

By the way, you just made you developpment server available publicly. I suggest restricting the access at least in the apache configuration..