Step-by-Step SSH CloudFront CDN Setup Tutorial 2026

Your SSH server is fine. The problem is your ISP thinks the handshake looks suspicious. That’s the whole reason people started fronting tunnels with CDNs — and CloudFront, with its always-free 1 TB of outbound data per month, became the obvious candidate. So here’s the honest SSH CloudFront CDN setup tutorial: what actually works, what quietly breaks, and the exact steps I run on every new box.

First, the Part Most Tutorials Get Wrong

You cannot point CloudFront at port 22. Full stop.

CloudFront only speaks HTTP and HTTPS. Its custom origin ports are limited to 80, 443, and the 1024–65535 range — port 22 is never in the list. So any guide telling you to “just add your VPS as an origin and SSH in” is either recycling a tutorial from 2018 or never tested it. I wasted an afternoon on that assumption once. Never again.

The fix is a WebSocket bridge. You wrap raw SSH traffic inside a WebSocket stream, CloudFront happily proxies that as ordinary HTTPS, and your client unwraps it at the other end. Two pieces: a bridge on the server, a bridge on your laptop.

Think of CloudFront as a very well-connected post office. It will deliver letters (HTTP), but it won’t hand-carry your package (raw TCP). Wrap the package in a letter and you’re back in business.

What You Need Before Starting

Gather these first. Half the failures I see in forums come from missing one item here, not from the config itself.

  • A VPS with a public IPv4 — pick a provider with decent peering, because your hosting terbaik choice determines 80% of your latency later
  • A domain you control, ideally a domain murah from a registrar with fast DNS (Cloudflare or Route 53 both work)
  • An AWS account — CloudFront’s free tier covers 1 TB transfer and 10 million requests monthly, permanently, not just for 12 months
  • The bridge binary: wstunnel is my default, though websocat works too
  • A working SSH key pair and a non-root sudo user on the VPS

No AWS account yet? You can absolutely test the whole flow against a bare CDN-less WebSocket endpoint first, then swap in CloudFront once the tunnel is proven. Debugging one variable at a time saves hours.

Step-by-Step: Building the Tunnel

Step 1 — Stand up the WebSocket bridge on your VPS

Install wstunnel, then run the server side so it listens locally and forwards to your real sshd:

wstunnel server wss://127.0.0.1:8080 --restrict-to 127.0.0.1:22

That single command gives you a plain-HTTP listener on port 8080 that upgrades to WebSocket paths and pipes them into local SSH. Bind it to 127.0.0.1 so nobody hits it directly — CloudFront will be the only visitor that matters.

Step 2 — Put a reverse proxy in front of it

CloudFront requires an HTTP origin on a permitted port. Nginx on 443 or 80 handling TLS termination and proxying to 127.0.0.1:8080 is the cleanest layout. Make sure you forward the Upgrade and Connection headers, or the WebSocket handshake dies at the proxy layer and you’ll blame CloudFront for something Nginx did.

Step 3 — Create the CloudFront distribution

  1. Origin domain: your VPS hostname (not an IP — CloudFront prefers a DNS name for origin verification)
  2. Origin protocol: HTTP only, port 80, if Nginx terminates TLS. If Nginx holds the cert, use HTTPS only on 443
  3. Viewer protocol policy: Redirect HTTP to HTTPS
  4. Allowed HTTP methods: all of them — WebSocket upgrades trip over GET/HEAD-only configs
  5. Cache policy: CachingDisabled (AWS managed). Absolutely non-negotiable
  6. Origin request policy: AllViewer, so query strings and headers reach your bridge intact

WebSocket support is on by default in modern distributions — no toggle to hunt for. Wait for the status to flip to Deployed, which usually takes 5–15 minutes.

Step 4 — Connect from your machine

Run the client-side bridge locally, then point SSH at it:

wstunnel client -L 2222:localhost:22 wss://d111abcdef8.cloudfront.net

ssh -p 2222 [email protected]

That’s it. Your traffic now leaves as TLS to a CloudFront edge, hops across AWS’s backbone, and lands on your origin as a boring HTTP request. On mobile, the same tunnel shape is what HTTP Injector, v2rayNG, and NekoBox are doing under the hood when you feed them a CDN hostname — the concepts transfer directly.

Settings That Quietly Break Things

  • Idle timeouts. CloudFront drops idle connections faster than a raw TCP session. Add ServerAliveInterval 30 to your SSH config or your session dies mid-apt upgrade
  • Path matching. If your bridge expects /tunnel, set the origin path accordingly — a mismatch returns a 403 that looks exactly like a permissions error
  • Geo restrictions. CloudFront isn’t available in every country. Check the supported list before blaming your config
  • Cache poisoning yourself. Any caching policy on a tunnel path is a bug waiting to happen. Disable it everywhere

Is It Worth the Complexity?

Honestly? For a two-person team, a plain WireGuard tunnel takes four minutes and zero AWS consoles. The CloudFront route earns its keep when your network path is actively hostile — restrictive corporate Wi-Fi, national filtering, mobile carriers that throttle anything that isn’t port 443 traffic to a well-known CDN.

Personally, I run CloudFront-fronted tunnels on maybe a third of my boxes. The ones in awkward regions. The rest stay plain, because debugging a CDN layer at 2 AM is nobody’s idea of fun. YMMV, and that’s fine.

Cost-wise: 1 TB free, then roughly $0.085/GB in the US. If you’re burning more than a terabyte a month on SSH, you’re probably not doing SSH anymore — and a VPN premium subscription might genuinely be cheaper than the egress bill. Run the numbers before you migrate everything. For a similar approach, check out Step.

FAQ

Can I skip the WebSocket bridge entirely?

Not with CloudFront. AWS never exposes raw TCP proxying on this product. Alternatives like Cloudflare Spectrum do, but that’s a paid add-on on a different platform.

Does this survive CloudFront’s free tier?

Yes, comfortably. 10 million requests monthly is enormous for interactive SSH. Your bottleneck will be data transfer, not request count.

Will my SSH client know the difference?

No. Once wstunnel maps localhost:2222 to your server’s port 22, everything — scp, rsync, port forwarding, tmux — behaves exactly like a normal connection.

What about ukuran latency?

Add 10–30 ms versus a direct connection, depending on how far you are from the nearest edge. For shell work you’ll never notice. For interactive X11 forwarding… you’ll notice.

Your Turn

Set it up on a throwaway VPS first — one hour of tinkering beats a week of guessing. And if you want a ready-to-use SSH account to test the client side before touching AWS, grab a free one at claudessh.com and point wstunnel at it.

Curious how it goes for you. What’s your actual use case — bypassing a stubborn network, or just learning how CDN fronting works? Drop it in the comments.

Similarly, QwenSSH SSH WebSocket offers free accounts with no registration across 196 countries.