How to host a website through VPS VPN on a local Server/PC
...or how to host a website behind a NAT
...or how to host TOR-like in normal web
...or how to hide host's geolocation
...or how to host via own VPN
...easily!

Please refer to this schema while reading further.

Initial idea:

Let's assume we need to:

Please refer to this schema while reading further.

Initial data:

We should have:

Recommended install parameters for OpenVPN Server.

Preparing server1:

I will show the concept using OpenVPN as an example tunneling software. You may try using any other one.

First, after connecting to our an Linux VPS, install OpenVPN server using this script:

wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh

Refer to the screenshot while entering parameters. (You should try using UDP!)

Setting up server0:

Time to install VPN client software on our local server0. I will use Windows as a sample local server (server0). For example, OpenVPN client software: https://openvpn.net/client-connect-vpn-for-windows/

Go to settings and tune it a bit - turn on seamless mode, autoconnect and disable prompts. Then import the file we created on our Linux VPS (usually from /root/client.ovpn) and connect.

After that, host anything on ip 10.8.0.2 and, say, port 1337. (ip may vary, refer to ipconfig of the server0).

I can see you!

Can you see me?

Go back to Linux VPS (server1) and execute the following:

apt-get install curl

curl -vvv 10.8.0.2:1337

If you see your html page you are serving or whatever, you can move on.

On this stage, your page is only accessible from your VPN server but not from the web.

inetd.conf file, the added line is selected.

Connecting last cables on Linux VPS:

Install Rinetd, the software that allows to redirect intenet traffic:

apt-get install rinetd

 Then configure it by adding a line specifying addresses and ports to "connect": vi /etc/rinetd.conf

To enter vi edit mode: i

To exit vi and save: Esc :wq Enter

Then update rinetd configuration file: reboot


These lines do all the magic.

Notice, that it may not always work. Usually you have to close ports on your router to prevent hosting directly, not via VPN.

Bonus tip - only host via VPN.

Right now, all the traffic is tunneled. But it's inconvenient! We only want to HOST website/web-service via VPN!

No problem! To do so, simply open out .ovpn file we created earlier and write this lines:

route-nopull 

route 10.8.0.1 255.255.255.255

Yes, our dark magic is done! Now, save and re-import the edited version .ovpn configuration and restart OpenVPN.

From now on, only web apps are being hosted via VPN! Our other connections like web surfing, SSH, AnyDesk are not being tunneled so we face the clear connection speed.

Our web app hosted on local server is liavailable worldwide!

Done! What next?

It works! Now your server's ip is ready to accept connections and no one will ever know that the web resource is actually hosted elsewhere.

The connection speed and bandwidth are almost uncut when using this tunnel. However, it may be noticeable on poor networks.

Ping from random device:

Pinging 92.255.109.84  with 32 bytes of data:
Reply from 92.255.109.84: bytes=32 time=46ms TTL=55
Reply from 92.255.109.84: bytes=32 time=45ms TTL=55
Reply from 92.255.109.84: bytes=32 time=45ms TTL=55
Reply from 92.255.109.84: bytes=32 time=45ms TTL=55

You may (you should!) try experimenting with different connection protocols and VPN software.

IPv6 should work too but does it have to be..?
Interested? Try connecting IPv4 address to IPv6 one or vice versa!