A Remote Desktop Gateway sits between the internet and your Windows VPS and turns a direct-RDP exposure problem into an HTTPS one. Instead of publishing 3389 and hoping the brute-force noise stays manageable, users authenticate to one public endpoint on port 443 and the Gateway opens the RDP connection internally on their behalf. This guide covers role installation, the certificate decision that trips up most deployments, the authorisation policies, and the firewalling that has to be right before you switch off direct RDP.
How the Gateway Actually Protects the VPS
RD Gateway performs three functions that matter on a small estate. It terminates a TLS connection on 443, so every client sees one HTTPS endpoint instead of a raw RDP port. It enforces a second authentication step — a connection authorisation policy that checks AD group membership before a tunnel is created. And it brokers the session so the back-end host can refuse 3389 from the internet entirely. A scanner pointing at your public IP finds a certificate-protected HTTPS listener, not an RDP handshake. For a handful of users the Gateway can share the session host; for anything larger it belongs on its own small VPS.
Prerequisites: Certificate, DNS, and Ports
Three things must be true before you install the role. Get them wrong and you will be debugging error 0x3000C.
- A public DNS name resolving to the VPS — e.g. gw.example.com. Clients must never connect by IP, because certificate validation requires a hostname match.
- A TLS certificate whose Subject or SAN contains that exact name. Self-signed works in a lab but forces every client to trust the issuer before the first connection — usually the real reason “it doesn’t work”.
- Firewall openings: TCP 443 inbound to the Gateway, and TCP 3389 between the Gateway and the session host if they are separate machines.
Installing the Role and Binding the Certificate
Install through Server Manager or PowerShell. The feature name is RDS-Gateway; the management console and service are the same either way:
Install-WindowsFeature RDS-Gateway -IncludeManagementTools
Get-Service TSGateway | Format-List Name,Status,StartType
Get-ChildItem Cert:\LocalMachine\My | Format-Table Subject,Thumbprint
$cert = (Get-ChildItem Cert:\LocalMachine\My |
Where-Object { $_.Subject -like "*gw.example.com*" }).Thumbprint
Set-Item -Path 'RDS:\GatewayServer\SSLCertificate\Thumbprint' -Value $cert
If the RDS: PowerShell drive is unavailable, the Gateway console exposes the same setting under Properties > SSL Certificates > Select an existing certificate. The PowerShell path is faster to repeat across hosts.
Authorisation Policies: The Part That Does the Work
The default policy is “creator owner, allow everything”, which is useless as a security control. Replace it with policies keyed to AD group membership and to the target computer. In the Gateway console, Policies > Connection Authorization Policies:
- CAP (who may connect): a named group such as GG-RDP-Users, with device redirection disabled unless the business case is explicit.
- RAP (where they may go): only the computer group holding your session hosts, and only TCP 3389. A RAP of “any computer, any port” turns the gateway into a general-purpose forwarder — the most common misconfiguration in this product.
By default the gateway authenticates passwords against AD, which is one factor only. If you need MFA, choose “password or smart card” in the CAP and let Microsoft Entra ID pre-authentication happen before RDP credentials are presented.
The Client .rdp File That Works
Distribute an .rdp file rather than instructions. The lines that matter are the gateway hostname, the remote host to reach, and whether to bypass the gateway for local resources:
gatewayhostname:s:gw.example.com
gatewayusagemethod:i:1
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:1
remoteapplicationmode:i:0
full address:s:app01.internal.example.com:3389
Value 1 for gatewayusagemethod means “use the gateway for everything, never bypass”. Set it to 0 (auto) and a client on the office LAN may silently skip the gateway — fine in a lab, a hole in production. A value of 2 (never use the gateway) is for troubleshooting only.
Closing the Direct RDP Path
The gateway only protects you if 3389 is no longer reachable from the internet. Once a test connection through the gateway succeeds, lock the session host firewall to the gateway address and remove any port-forward or load-balancer rule that published 3389:
Remove-NetFirewallRule -DisplayName 'Remote Desktop - User Mode (TCP-In)' -ErrorAction SilentlyContinue
New-NetFirewallRule -DisplayName 'RDP from RD Gateway only' -Direction Inbound `
-Protocol TCP -LocalPort 3389 -RemoteAddress 203.0.113.10 -Action Allow
Test from an external network before you celebrate. Try connecting to the public IP on 3389 and confirm the SYN is dropped rather than answered. A timeout is the correct result; a refused connection means something upstream is still answering.
Troubleshooting the Errors You Will Actually See
| Error | Meaning | Fix |
|---|---|---|
| 0x3000C “remote computer can’t be found” | Gateway could not resolve or reach the target | Check DNS on the gateway, then Test-NetConnection to the target on 3389 |
| 0x604 “RD Gateway server is unavailable” | 443 blocked or service stopped | Check the TSGateway service and the inbound 443 rule |
| 0x0308 “did not approve this connection” | RAP denied the target | Add the computer group to the RAP |
| 0x3000A “certificate is not valid” | Name mismatch or expired | Bind a certificate whose SAN matches the FQDN |
Most 0x604 errors are a load balancer in front of the VPS that never had 443 opened, not a problem with the role. Probe from outside before touching the gateway configuration — and note that a gateway protects nothing if the session host still answers on the public IP, so the firewall step above is not optional.
Where the Gateway Fits in a Hardening Plan
The gateway replaces direct exposure; it does not replace NLA, account lockout, or restricted admin mode, which still apply behind it. If you are choosing a plan for this topology, a second small VPS for the gateway is usually cheaper than the operational risk of exposing the session host — the Windows VPS hosting plans and specifications describe the entry tiers that suit it. For the surrounding controls, the Windows VPS remote access and hosting guide covers the rest of the sequence.



