~/blog/browser-based-rdp-cloudflare-tunnels
$ cat metadata.json
{"title": "Secure Your Windows Desktop: Browser-Based RDP with Cloudflare Tunnels"}

Secure Your Windows Desktop: Browser-Based RDP with Cloudflare Tunnels

Access your full Windows desktop remotely from any browser without opening ports or using a VPN. Learn how to implement secure browser-based RDP using Cloudflare Tunnels and Zero Trust Access.

Roberts Batars
#rdp #cloudflare #windows #remote-desktop #zero-trust #security

Secure Your Windows Desktop: Browser-Based RDP with Cloudflare Tunnels

Remote Desktop Protocol (RDP) is essential for accessing a full Windows desktop remotely, but exposing the RDP port (3389) to the internet is a massive security risk. It’s one of the first things malicious bots scan for. Traditional VPNs can be slow and clunky.

My goal was to find a way to access my full Windows 11 Pro desktop - with all my files and applications - from any computer, using only a web browser, and without opening a single port on my router. This guide details how I achieved this using Cloudflare Tunnels and Access.

The Security Model: Zero Ports Open

The core of this setup is a Cloudflare Tunnel. Instead of me connecting in to my home network, a lightweight service on my PC (cloudflared) creates a secure, outbound-only connection out to Cloudflare’s network. My home network remains completely dark and invisible to the public internet, eliminating the attack surface.

Step 1: Hardening Windows for Remote Access

Before connecting anything to the outside world, I had to make sure the PC itself was secure.

Enable Remote Desktop: First, I had to enable Remote Desktop on Windows. I went to Settings > System > Remote Desktop and turned it on. I was fortunate that my Windows 11 Pro edition supports this feature natively - note that Windows Home editions do not include Remote Desktop functionality, so you’ll need Pro, Enterprise, or Education editions.

Strong Password: This is non-negotiable. I ensured my Windows account uses a strong, unique password.

Cache Your Microsoft Password: This was the source of a major headache and is critical to understand. RDP requires your Microsoft account password to be cached locally on Windows, but if you only sign in with Windows Hello (PIN, fingerprint, or face), Windows never caches your actual password. To fix this, I had to temporarily disable the Windows Hello requirement: I went to Settings > Accounts > Sign-in options and turned OFF the setting “For improved security, only allow Windows Hello sign-in…”. Then - and this is the crucial step - I logged out of Windows completely and logged back in using my full Microsoft account password. This forces Windows to cache the password locally. After logging in successfully, I re-enabled the Windows Hello setting. Windows Hello provides convenient, hardware-backed local authentication via TPM (if your PC has TPM), while the cached password enables RDP remote access. Note: If you’ve previously logged into Windows with your Microsoft password (before setting up Hello), it may already be cached, and this step might not be necessary.

Enable NLA: In my system’s “Remote Desktop” settings, I ensured Network Level Authentication (NLA) was enabled, which forces authentication before a full session is established.

Disable Fast Startup: This feature can cause issues with remote connections and Wake-on-LAN, so I disabled it in my Power Options.

Step 2: Setting Up the RDP Tunnel

This was surprisingly simple using Cloudflare’s dashboard.

Create the Tunnel: In the Cloudflare Zero Trust dashboard, I navigated to Networks > Tunnels and created a new tunnel called rdp-laptop.

One-Command Install: The dashboard provided a single, unique command to run on my PC. I opened Command Prompt as an Administrator, pasted the command, and it automatically installed cloudflared as a permanent Windows service. My laptop was now connected.

Step 3: Configuring the Tunnel for RDP

With the connector running, I had to tell Cloudflare what to do with it.

Define the Network: In the tunnel’s configuration, I went to the Private Networks tab and added the CIDR for my home network (e.g., 192.168.1.0/24). This tells the tunnel which local network it’s responsible for.

Create a Target: In Networks > Targets, I created a bookmark for my PC. I named it my-windows-laptop and pointed it to my PC’s static local IP address. This is a mandatory step in the current Cloudflare UI.

Step 4: Building the Secure RDP Application

This is the final step that ties everything together and makes it accessible.

In Access > Applications, I created a new Self-hosted application.

I assigned it a public hostname, like remote.yourdomain.com.

The magic happens in the Browser rendering settings, where I selected RDP.

I configured it to use the my-windows-laptop target on port 3389.

I created a strict Access Policy to only allow my personal email address to log in.

For extra security, in the application’s “Advanced settings,” I enabled the HttpOnly cookie attribute. This prevents malicious scripts from stealing my session cookie.

Finally, I enabled “Show in App Launcher” for one-click access.

Troubleshooting & Lessons Learned

The biggest challenge was the Windows login itself. My Microsoft Account email and password kept failing with an “authentication failure” message.

The Solution: The RDP service doesn’t use the Microsoft email address. It uses a hidden, internal username. I found the correct username by opening Command Prompt on my laptop and running the whoami command. The output was in the format PC_NAME\username (e.g., LAPTOP-NAME\user). Using this username with my full Microsoft account password worked perfectly. It’s also critical to remember that the Windows Hello PIN will never work for RDP.

The result is a highly secure RDP setup that I can access from my university library or anywhere else, using only a browser, with the peace of mind that my home network is completely locked down.