ESP32 and VPNs: server, client, or no VPN at all

The usual reason to want a VPN on an ESP32 is simple: reach its web page or its API from somewhere else, safely. There are four ways to get there, and only one of them puts the VPN on the ESP32.

An ESP32 as a VPN server

A VPN server waits for clients to connect to it, so it has to be reachable from the internet: a public IP address and a forwarded port on the router in front of it. That is exactly what an ESP32 behind someone else's router, a 4G modem or carrier-grade NAT does not have. If you can forward a port to the ESP32, you can already reach its web server directly, and the VPN only adds encryption on top. In practice it is not done: the server side belongs on something with more memory, on the edge of the network.

A WireGuard client on the ESP32

The other way round works. The ESP32 connects out to a WireGuard server you run (a small VPS, or your home router), and anyone on that VPN reaches the device by its VPN address. There is a community WireGuard implementation for ESP-IDF; Tailscale and ZeroTier have no official client for the ESP32.

It is a reasonable choice for a handful of devices you own, on networks you know.

The VPN on the router or a Raspberry Pi

If the devices sit on a network you control, put the VPN on the router, or on a Raspberry Pi on the same network acting as a subnet router (Tailscale and WireGuard both do this). The ESP32 runs nothing extra and keeps all its memory, and you reach every device on that network by its local address. This is the best answer at home or in your own building. It does not help with a device on a customer's network, where you cannot install anything next to it.

No VPN: an outbound tunnel

The device opens one outbound connection to a service, and the service gives its web page a public HTTPS address. Nothing is opened on the router, nothing runs next to the device, and nobody needs a VPN client to open the page: a browser is enough, with sign-in or a share link deciding who gets in. This is what Pinscope does. Its connection uses the Noise protocol, the same family of handshake WireGuard is built on, in 9.4 KB of RAM, and the same connection carries the device's logs, crash reports and firmware updates.

Which one

Works on someone else's networkRuns on the ESP32To open the page
ESP32 as VPN serverNo: needs a forwarded portA VPN serverVPN client
WireGuard client on the ESP32YesWireGuardVPN client, and a server you run
VPN on the router or a PiOnly where you can add the router or PiNothingVPN client
Outbound tunnel (Pinscope)YesOne componentA browser

For more on the trade-offs between tunnels, see port forwarding, ngrok, Cloudflare Tunnel and Tailscale compared.

Try it

Three devices are free, and no card is needed. Create an account, or read the five-minute guide first.

More