Cần điều khiển PC Windows ở nhà từ xa mà không muốn expose RDP ra Internet? Cloudflare Tunnel + Access cho phép client chỉ cần trình duyệt và cloudflared — không bắt buộc VPN cài trên máy công ty.
Why not expose port 3389?
When I needed my home Windows PC from elsewhere, I used WireGuard into the LAN, then RDP to a private IP. Upside: no 3389 on the public Internet, less drive-by scanning. Downside: corporate laptops often block third-party VPN clients — that path disappears.
Cloudflare Tunnel (cloudflared inside the LAN) maintains an outbound path to Cloudflare. You attach a public hostname pointing at LAN_IP:3389 with service type RDP. Remote machines never hit your home router’s RDP port directly; Cloudflare sits in front, and you can add Cloudflare Access (Zero Trust) so only approved identities pass.
Prerequisites
- A Windows PC on the LAN with Remote Desktop enabled and a user allowed to sign in remotely.
- A Cloudflare account with your domain on the zone.
- A tunnel already created and
cloudflaredrunning on a host in the LAN (Windows, Linux, or a container). If you do not have one yet, follow Create a tunnel (dashboard) and Install cloudflared.
Step 1 — Public hostname (RDP)
- Open Zero Trust → Networks → Tunnels → select your tunnel.
- Public Hostname tab → Add a public hostname.
- Set:
- Subdomain + Domain (e.g.
rdp+example.com→rdp.example.com). - Service type: RDP.
- URL: LAN IP of the target PC and port — typically
192.168.x.x:3389.
- Subdomain + Domain (e.g.
- Save hostname.
Keep the full hostname; the client uses it with cloudflared access rdp --hostname ....
Step 2 — Connect from outside the LAN
On the client, cloudflared authenticates through Cloudflare and listens locally; your RDP app connects to localhost, not your home IP.
Install cloudflared on the client
- macOS / Windows / Linux: Install cloudflared.
- Arch-based distros (example):
yay -S cloudflaredor your distro’s package.
RDP client
- Windows: Remote Desktop Connection (built in).
- Linux: Remmina, FreeRDP, etc.
Run the access proxy
On the client (leave the terminal open):
cloudflared access rdp --hostname rdp.example.com --url rdp://localhost:3389
Replace rdp.example.com with your hostname.
Open the RDP client and connect to localhost:3389 — not the LAN IP or the public hostname in mstsc/Remmina. With a healthy tunnel and service mapping, you should get the Windows sign-in UI.
This command binds a local listener. Each remote session needs cloudflared access rdp running (or your own wrapper script/service).
Step 3 — Zero Trust: hostname alone is not enough
A public hostname without Access means anyone who guesses the URL might attempt a connection. Add an Application:
- Zero Trust → Access → Applications → Add an application.
- Self-hosted.
- Application name: e.g.
Home RDP. - Subdomain + Domain: same hostname as the tunnel route (e.g.
rdp.example.com). - Next → create a Policy:
- Policy name: your choice.
- Action: Allow.
- Include: e.g. Emails → allowed addresses.
- Finish Add application.
Access can send a one-time email PIN (or use another IdP if configured). Users who fail the policy never complete the cloudflared proxy step.
Retry with Access enabled
- Run again:
cloudflared access rdp --hostname rdp.example.com --url rdp://localhost:3389
- The browser opens Cloudflare Access → enter email → confirm OTP → Approve if prompted.
- The terminal may show a waiting-for-login state; RDP to
localhost:3389should then prompt for Windows credentials.
That is the split I rely on: Access (who may open the tunnel path) plus Windows login (who may use the session).
Quick comparison with LAN VPN
| WireGuard into LAN | Cloudflare Tunnel + Access | |
|---|---|---|
| Software on a locked-down work PC | Often blocked | cloudflared + RDP only (sometimes easier than VPN) |
| Router port forward | Not required for outbound VPN | Not required — outbound tunnel |
| Depends on Cloudflare | No | Yes — understand their trust boundary |
| Public-IP brute force on 3389 | Avoided if no port forward | 3389 not exposed |
Security and operations
- Strong Windows passwords (and MFA where possible) still matter; Access does not replace OS authentication.
- Tighten Access policies (email, groups, geography) instead of open allow rules.
- Keep
cloudflaredupdated on the tunnel host and clients per Cloudflare downloads. - If the PC’s LAN IP changes, update the public hostname URL (DHCP reservation helps).
Wrap-up
RDP over Cloudflare Tunnel lets me reach a home Windows box without publishing 3389 to the Internet, and Access keeps the hostname from becoming a public door. Day-to-day flow: tunnel + RDP hostname on the LAN → cloudflared access rdp on the client → RDP to localhost:3389.
Further reading: Cloudflare Tunnel · Access applications · RDP with cloudflared
Vì sao không mở port 3389?
Trước đây khi cần vào máy Windows ở nhà, tôi hay dùng WireGuard để vào LAN, rồi RDP qua IP nội bộ. Ưu điểm: không phải publish cổng 3389 ra Internet, ít bị quét brute-force. Nhược điểm: máy công ty thường không cho cài client VPN — gần như chặn hẳn cách làm này.
Cloudflare Tunnel (cloudflared chạy trong LAN) tạo kết nối outbound tới Cloudflare. Bạn gắn public hostname trỏ vào LAN_IP:3389 với loại RDP. Máy ở ngoài không “đụng” thẳng router nhà; Cloudflare đứng giữa, và bạn có thể thêm Cloudflare Access (Zero Trust) để chỉ email được phép mới mở được tunnel.
Yêu cầu chuẩn bị
- PC Windows trong LAN: bật Remote Desktop, user có quyền đăng nhập từ xa (hoặc nhóm Remote Desktop Users).
- Tài khoản Cloudflare với domain đã add vào zone.
- Tunnel đã tạo và
cloudflaredđang chạy trên một host trong LAN (máy Windows, Linux, hoặc container). Nếu chưa có tunnel, làm theo Create a tunnel (dashboard) hoặc Install cloudflared.
Bước 1 — Public hostname kiểu RDP
- Vào Zero Trust → Networks → Tunnels → chọn tunnel đang dùng.
- Tab Public Hostname → Add a public hostname.
- Điền:
- Subdomain + Domain (ví dụ
rdp+example.com→rdp.example.com). - Service type: RDP (dashboard map đúng giao thức cho client
cloudflared access rdp). - URL: IP LAN của PC cần remote và port — thường
192.168.x.x:3389.
- Subdomain + Domain (ví dụ
- Save hostname.
Ghi lại hostname đầy đủ; client sẽ dùng nó với lệnh cloudflared access rdp --hostname ....
Bước 2 — Kết nối từ máy bên ngoài LAN
Ý tưởng: cloudflared trên máy client xác thực qua Cloudflare, mở proxy local; RDP client kết nối vào localhost thay vì IP nhà.
Cài cloudflared trên máy client
- macOS / Windows / Linux: Install cloudflared.
- Arch / EndeavourOS (ví dụ):
yay -S cloudflaredhoặc package tương đương distro của bạn.
RDP client
- Windows: Remote Desktop Connection (có sẵn).
- Linux: Remmina, FreeRDP (
freerdp), v.v.
Thiết lập proxy RDP
Trên máy client, chạy (giữ terminal mở):
cloudflared access rdp --hostname rdp.example.com --url rdp://localhost:3389
Thay rdp.example.com bằng hostname bạn đã tạo.
Mở RDP client, kết nối tới localhost:3389 (không dùng IP LAN hay hostname public trực tiếp trong Remmina/mstsc). Nếu tunnel và service đúng, bạn sẽ thấy màn hình đăng nhập Windows.
Lệnh trên tạo local listener. Mỗi phiên remote cần terminal chạy cloudflared access rdp (hoặc script/service riêng nếu bạn tự đóng gói).
Bước 3 — Zero Trust: không để “ai biết URL cũng vào”
Chỉ public hostname chưa đủ: người lạ có thể thử kết nối nếu đoán được subdomain. Thêm Application trong Access:
- Zero Trust → Access → Applications → Add an application.
- Chọn Self-hosted.
- Application name: tên gợi nhớ (ví dụ
Home RDP). - Subdomain + Domain: cùng hostname đã gắn tunnel (ví dụ
rdp.example.com). - Next → tạo Policy:
- Policy name: tùy chọn.
- Action: Allow.
- Include: ví dụ Emails → danh sách email được phép.
- Hoàn tất Add application.
Access có thể dùng one-time PIN qua email (hoặc IdP khác nếu bạn cấu hình). Ai không pass policy sẽ không mở được bước proxy cloudflared.
Thử lại sau khi bật Access
- Chạy lại:
cloudflared access rdp --hostname rdp.example.com --url rdp://localhost:3389
- Trình duyệt mở trang Cloudflare Access → nhập email → xác nhận OTP → Approve nếu được hỏi.
- Terminal có thể hiện trạng thái chờ đăng nhập; RDP client tới
localhost:3389hiện prompt user/password Windows.
Đó là luồng tôi dùng: Access (ai được vào) + RDP credentials (ai được vào session Windows).
So sánh nhanh với VPN LAN
| WireGuard vào LAN | Cloudflare Tunnel + Access | |
|---|---|---|
| Cài phần mềm trên máy công ty | Thường bị chặn | Chỉ cần cloudflared + RDP (đôi khi dễ hơn VPN) |
| Mở port trên router | Không (nếu chỉ outbound VPN) | Không — tunnel outbound |
| Phụ thuộc Cloudflare | Không | Có — cần hiểu trust model |
| Brute-force 3389 trên IP công cộng | Không nếu không NAT port | Không expose 3389 |
Lưu ý bảo mật và vận hành
- MFA Windows và password mạnh vẫn bắt buộc; Access không thay thế OS login.
- Giới hạn policy Access (email, group, country…) thay vì “Allow everyone”.
- Cập nhật
cloudflaredtrên host tunnel và máy client theo release notes. - Nếu PC đổi IP LAN, sửa URL trong public hostname cho khớp DHCP/reservation.
Kết
Cloudflare Tunnel cho RDP giúp tôi remote Windows ở nhà mà không phải forward 3389 ra Internet, và thêm Access để hostname không trở thành “cửa hở”. Workflow thực tế: tunnel + hostname RDP trên LAN → cloudflared access rdp trên client → RDP vào localhost:3389.
Đọc thêm: Cloudflare Tunnel · Access applications · RDP with cloudflared
