Overcoming NAT

Do I need this?

Only if you booked a VM without a dedicated IPV4 (NAT) on p2pcloud.

Using Cloudflare tunnels

Create a tunnel

Cloudflare is a fast and free way to expose your web service without having a dedicated IPV4.

Open https://one.dash.cloudflare.com/. Login or register. Then Navigate Acess->Tunnels.

Cloudflare tunnels menu

Click “Create tunnel”

Cloudflare create tunnel

Name it

name the tunnel

Launch the tunnel on your VM

Select docker and copy your launch command

docker launch cloudflare tunnel

If you don’t have docker installed, just type apt update && apt install -y docker.io.

Copy your launch command, and add --net=host -d --name cloudflared right after docker run. You will have something like that:

1
docker run --net=host -d --name cloudflared cloudflare/cloudflared:latest tunnel --no-autoupdate run --token [your token here]

Check logs

1
docker logs cloudflared

It should report successful connections

cloudflared logs

Launch example service

1
docker run -d --name app -p 127.0.0.1:12345:80 strm/helloworld-http:latest

Connect the service to your domain on Cloudflare

Click “next” and use any subdomain you want. Use 127.0.0.1:12345 as an endpoint, that’s where your container example listening.

cloudflared tunnel hostname setup

That’s it! Here is your app served on cloudflare without any port forwarding or dedicated IPs:

browser with app running

Optional: Load balancing and high availability

You can run the same 2 containers app and cloudflared on another VM and get round-robin load balancing and high availability.

browser with app running

Try restarting cloudflared on both servers if load balancing is not working right away.