Networks & Security4 min read

Unleashing the Power of Cloudflare Tunnel: A Step-by-Step Guide by NETREGIA

Step-by-step guide to deploying Cloudflare Tunnel with cloudflared CLI to eliminate inbound firewall port forwarding, illustrated by NETREGIA's YASMINAGLACES rollout.

iBrahim Bouraye — Founder & Lead IT Architect · NETREGIA Casablanca
iBrahim BourayeFounder & Lead IT Architect · NETREGIA Casablanca

Direct Answer · Executive Summary

Cloudflare Tunnel replaces fragile legacy VPNs and risky inbound router port forwarding with outbound encrypted tunnels established by the lightweight cloudflared daemon. In this step-by-step guide, NETREGIA demonstrates how YASMINAGLACES connected internal servers and databases to remote employees using Zero Trust routing, CLI configuration, and full validation.

Key Takeaways

  • Outbound cloudflared tunnels eliminate exposed public ports and reduce firewall attack surfaces compared to traditional VPN concentrators.
  • Deploy in four CLI steps: authenticate with cloudflared tunnel login, create the tunnel, configure config.yml ingress, and route DNS.
  • Run cloudflared as a hardened Linux systemd service so encrypted tunnels survive server reboots automatically.
  • As proven at YASMINAGLACES, pairing technical validation with staff onboarding ensures fast adoption across distributed teams.
Table of Contents (5)

In today's digital landscape, guaranteeing secure and reliable remote connectivity is critical for businesses of every size. Virtual Private Networks (VPNs) have long served as the standard way to connect remote staff to corporate servers while keeping internal traffic private. However, legacy VPN appliances are often complex to maintain, costly to license, and expose public ports directly to the internet.

Cloudflare Tunnel solves this problem by allowing your infrastructure to establish outbound-only encrypted connections to Cloudflare's global edge—exposing internal applications safely without opening a single inbound firewall port. Below, we share how NETREGIA leveraged Cloudflare Tunnel to build a tailored Zero Trust remote access architecture for our client YASMINAGLACES, along with the exact step-by-step CLI workflow.

The Challenge: Replacing Complex Legacy VPNs

Understanding YASMINAGLACES' Requirements: Before touching any configuration, NETREGIA conducted a thorough audit of YASMINAGLACES' security policies, performance targets, and daily staff workflows. Understanding how employees accessed internal tools enabled us to design a custom, friction-free connectivity layer.

Initial Tunnel Provisioning: NETREGIA provisioned a dedicated Cloudflare account for YASMINAGLACES and established an encrypted tunnel linking their internal infrastructure to the Cloudflare edge, applying Zero Trust access controls to protect sensitive company data.

Integrating the custom remote-access tunnel seamlessly with YASMINAGLACES' existing systems was a decisive milestone—ensuring full compatibility and high responsiveness across their active servers and internal databases.

Step-by-Step Technical Setup with cloudflared CLI

Once the tunnel architecture was mapped to YASMINAGLACES' servers, databases, and internal line-of-business apps, NETREGIA deployed the lightweight cloudflared daemon directly inside their local environment:

  1. Install and authenticate cloudflared on the Linux host: Download the official package for Debian/Ubuntu and link the daemon to your Cloudflare Zero Trust account:
    curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
    echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflared.list
    sudo apt-get update && sudo apt-get install -y cloudflared
    cloudflared tunnel login
  2. Create a named tunnel: Generate a dedicated tunnel identifier and credentials JSON file on the host:
    cloudflared tunnel create yasminaglaces-tunnel
  3. Configure ingress routing in /etc/cloudflared/config.yml: Map each internal service hostname to its private LAN port while enforcing a catch-all 404 fallback rule:
    tunnel: <TUNNEL_UUID>
    credentials-file: /root/.cloudflared/<TUNNEL_UUID>.json
    
    ingress:
      - hostname: app.yasminaglaces.example
        service: http://127.0.0.1:8080
      - hostname: db-admin.yasminaglaces.example
        service: https://192.168.10.20:443
        originRequest:
          noTLSVerify: false
      - service: http_status:404
  4. Route DNS and activate the persistent system service: Bind the Cloudflare CNAME record automatically and run the tunnel as an auto-restarting systemd daemon:
    cloudflared tunnel route dns yasminaglaces-tunnel app.yasminaglaces.example
    sudo cloudflared service install
    sudo systemctl enable --now cloudflared
    sudo systemctl status cloudflared

With this outbound daemon active, YASMINAGLACES employees gained authenticated, encrypted access to internal servers and databases from any authorized location—with zero public ports exposed on the office router.

Testing and Validation

Before releasing the solution into production, NETREGIA ran end-to-end validation across three areas:

  • Connectivity and failover checks: Verifying automatic daemon reconnection after local ISP drops and server reboots.
  • Latency and throughput benchmarking: Ensuring application responsiveness matched on-premise expectations.
  • Security and access policy auditing: Confirming unauthorized users were blocked at Cloudflare's edge and zero inbound router ports remained open.

All test benchmarks were reviewed and signed off jointly with YASMINAGLACES before final cutover.

Deployment and Team Training

In the final phase, NETREGIA rolled out Cloudflare Tunnel across YASMINAGLACES' operational teams and delivered hands-on training so administrators could monitor tunnel health, onboard new staff, and maintain policies autonomously.

Solution and Business Impact

Through NETREGIA's engineering and Cloudflare Tunnel's Zero Trust model, YASMINAGLACES now operates a secure, reliable, and effortless remote access infrastructure without legacy VPN friction. Looking to eliminate exposed firewall ports and modernize remote access across your offices? Explore our managed IT and Zero Trust networking solutions or contact NETREGIA to plan your Cloudflare Tunnel rollout.

Dedicated Enterprise Solution

Ready to deploy: Managed IT Services, Cloud & Multi-WAN Networks

Our Casablanca engineering team delivers an actionable technical audit, clear architecture roadmap, and contractual ~5 min SLA response.

iBrahim Bouraye — Founder & Lead IT Architect · NETREGIA Casablanca
About the Author

iBrahim Bouraye

Founder & Lead IT Architect · NETREGIA Casablanca

Founder and Principal Systems Architect at NETREGIA in Casablanca with 18+ years of field experience designing Odoo ERP deployments, DGI 2026 e-invoicing pipelines, Multi-WAN high-availability networks, and Zero Trust security for Moroccan enterprises.

Schedule a technical consultation
CallWhatsApp24h Audit