Hide Your Server's IP While Exposing Your Service

In this post we are going to explain how to expose our service through a Cloudflare VPN for free, no matter where we are deploying.

Why this is important?

When exposing our service directly to the internet, we lack the ability to effectively manage a DDoS attack. Instead, we can use Cloudflare as a reverse proxy and delegate that responsibility to them. Another key reason is that we should avoid exposing our IP address at all costs. This enhances our privacy and helps prevent issues like censorship. For instance, if an ISP or agency wanted to censor us, they would need to block a Cloudflare nameserver, which would disrupt countless other websites as well.

Top 5 IT Companies Using Cloudflare Protection

  • IBM

  • GitHub

  • GitLab

  • Atlassian

  • Zendesk

How to use Cloudflare zero trust?

Create a "Tunnel" under zero trust > networks > tunnels.

Run a cloudflare vpn on your server.

I am using a docker container but you can use cloudflared cli as well.

version: '3'
services:
  httpd_alpine_demo:
    image: httpd:alpine
  vpn:
    image: cloudflare/cloudflared
    restart: unless-stopped
    command: tunnel run
    environment:
      - TUNNEL_TOKEN=_CLOUDFLARE_TOKEN_

View docker-compose.yml file on GitHub

As you may notice, we donโ€™t need to expose our Docker service port to the host because both services are on the same network.

We should use the service name we are exposing as dns.

And that's it !

You can Visit Demo and follow us on GitHub !

;