Public Wi-Fi at hotels and airports sees everything your devices send, commercial VPNs charge a monthly fee to route your traffic through their servers, and reaching your homelab from outside usually means exposing services to the internet. A self-hosted WireGuard VPN solves all three: your phone and laptop tunnel back to a machine you control, with modern cryptography, low resource usage, and no subscription. The traditionally annoying part was managing it by hand, writing client configs and generating QR codes on the command line.

wg-easy removes that friction. It packages a WireGuard server with a web UI for creating clients, showing QR codes, and watching connection stats. This guide deploys wg-easy with the official Docker Compose file, covers the kernel-module and firewall steps that trip people up, connects your first phone, and puts the admin panel behind HTTPS. Budget about 30 minutes.

If you have used Tailscale, wg-easy is the fully self-owned alternative: no coordination server, no third-party account, just a UDP tunnel into your own machine.

What is wg-easy?

wg-easy is an open-source container that runs a WireGuard server and a web management UI together. From the dashboard you can create, edit, enable, disable, and delete clients, show each client’s QR code or download its config file, rotate key pairs, manage preshared keys, and see per-client transfer charts. Version 15 adds two-factor authentication, per-client firewall filtering, Prometheus metrics, client expiration dates, one-time sharing links, and optional OAuth or OIDC login through providers such as Authentik.

WireGuard itself does the heavy lifting. It has been part of the mainline Linux kernel since version 5.6, uses a small, modern set of cryptographic primitives, and reconnects quickly when a phone switches between Wi-Fi and mobile data. Compared with OpenVPN, it is simpler to configure and usually faster.

Everything below follows the official wg-easy documentation, including the Compose file.

What you need

  • A Linux host with a public IP address or a domain name pointing at it. A small VPS works, and so does a home server behind a router you can configure for port forwarding. The project supports x86_64 and arm64, which includes a Raspberry Pi 4 or 5.
  • Docker with the Compose plugin. Our Docker basics guide covers installation.
  • UDP port 51820 reachable from the internet.
  • About 30 minutes.

Step 1: Prepare the host kernel

WireGuard runs in the kernel, and wg-easy sets up NAT with iptables, so two kernel modules must be available. Most current distributions ship both. Load them now and make them load at boot:

sudo modprobe wireguard
sudo modprobe iptable_nat
echo "wireguard" | sudo tee -a /etc/modules
echo "iptable_nat" | sudo tee -a /etc/modules

These commands come from the wg-easy FAQ, where they fix the two most common startup errors: Cannot find device "wg0" and can't initialize iptables table 'nat'. If you use IPv6, the FAQ lists the matching ip6table_nat module as well.

Step 2: Deploy with the official Compose file

The project publishes its Compose file in the repository. Download it rather than retyping it, so you get the exact version the maintainers test:

sudo mkdir -p /etc/docker/containers/wg-easy
sudo curl -o /etc/docker/containers/wg-easy/docker-compose.yml \
  https://raw.githubusercontent.com/wg-easy/wg-easy/master/docker-compose.yml

At the time of writing, the file looks like this:

volumes:
  etc_wireguard:

services:
  wg-easy:
    #environment:
    #  Optional:
    #  - PORT=51821
    #  - HOST=0.0.0.0
    #  - INSECURE=false

    image: ghcr.io/wg-easy/wg-easy:15
    container_name: wg-easy
    networks:
      wg:
        ipv4_address: 10.42.42.42
        ipv6_address: fdcc:ad94:bacf:61a3::2a
    volumes:
      - etc_wireguard:/etc/wireguard
      - /lib/modules:/lib/modules:ro
    ports:
      - "51820:51820/udp"
      - "51821:51821/tcp"
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv6.conf.all.disable_ipv6=0
      - net.ipv6.conf.all.forwarding=1
      - net.ipv6.conf.default.forwarding=1

networks:
  wg:
    driver: bridge
    enable_ipv6: true
    ipam:
      driver: default
      config:
        - subnet: 10.42.42.0/24
        - subnet: fdcc:ad94:bacf:61a3::/64

Three parts of this file deserve attention.

The image tag. Use 15, the current major version (the latest release is v15.5.0). It receives new minor releases without breaking changes. The project’s tagging table explicitly says to avoid latest, because that tag still points to the old v14 release.

Capabilities and sysctls. NET_ADMIN lets the container create the WireGuard interface, and the sysctls block turns on packet forwarding. Without them, clients connect but no traffic reaches the internet.

The etc_wireguard volume. It stores the server keys, every client configuration, and the wg-easy database. This is the one thing you must back up.

Start the stack and watch the logs:

cd /etc/docker/containers/wg-easy
sudo docker compose up -d
sudo docker compose logs -f

Step 3: Create the admin account and your first client

On first start, wg-easy opens a setup wizard on port 51821. Reach it over your LAN or an SSH tunnel (ssh -L 51821:localhost:51821 user@server, then browse to http://localhost:51821). The wizard asks for an admin username and password, then the public host clients will connect to: your domain name or public IP address.

For automated deployments, the docs describe an unattended setup. Set INIT_ENABLED=true together with INIT_USERNAME, INIT_PASSWORD, INIT_HOST, and INIT_PORT; these four belong to one group and must be set together. They apply only on the first start, and the docs recommend removing them afterwards so the password does not stay in your Compose file.

After logging in, click New Client and give it a descriptive name such as phone. wg-easy generates the key pair immediately. Click the QR code icon and scan it with the official WireGuard app on iOS or Android, or download the .conf file for the desktop client. No certificates and no manual editing are involved.

By default a client sends all of its traffic through the tunnel, which is what you want on untrusted Wi-Fi. If you only want to reach your home network, change that client’s allowed IPs to your LAN range. To restrict what a client may reach on the server side, enable the per-client firewall under Admin Panel → Interface → Traffic Filtering. The FAQ notes that, unlike allowed IPs, these server-side rules cannot be bypassed by editing the client config.

Step 4: Open the firewall and forward the port

Clients connect on UDP 51820, and that is the only port the docs require you to open. With ufw:

sudo ufw allow 51820/udp

On a VPS, also allow the port in the provider’s firewall panel. At home, forward UDP 51820 on your router to the Docker host. Do not forward TCP 51821 to the internet. The web UI should stay reachable only from your LAN, from inside the VPN, or through the reverse proxy described next.

Test from your phone on mobile data with Wi-Fi turned off. Enable the tunnel in the WireGuard app; the wg-easy dashboard should show the client as connected with its traffic counters climbing. A useful second check is to search “what is my IP” on the phone and confirm it shows your server’s address.

Step 5: Put the admin panel behind HTTPS

The web UI listens on plain HTTP, and wg-easy expects a TLS reverse proxy in front of it for anything beyond local access. With Caddy, one site block is enough:

vpn.example.com {
    reverse_proxy localhost:51821
}

When the proxy runs in its own container, tell wg-easy which proxy addresses to trust with the TRUSTED_PROXIES variable. Only those addresses may supply X-Forwarded-* headers, and a non-empty list also enables CSRF origin checks:

environment:
  - TRUSTED_PROXIES=172.18.0.2

Replace the address with your proxy container’s IP or subnet and restart wg-easy after changing it. The docs warn that an invalid entry prevents startup, which at least fails loudly. The project also publishes dedicated Caddy and Traefik tutorials.

If you never want the panel reachable from outside, you can skip the proxy and set INSECURE=true to allow login over plain HTTP. The documentation labels this option insecure; use it only when the UI is confined to your local network. Connecting to the VPN first and then opening the panel through the tunnel is a good middle ground.

Updates and backups

Because the Compose file pins the major version, updates are two commands:

cd /etc/docker/containers/wg-easy
sudo docker compose pull
sudo docker compose up -d

Clients reconnect within seconds. Read the release notes before a major-version jump; the docs include a separate migration guide for v14 to v15, and v16 will need the same care.

For backups, copy the etc_wireguard volume. If you lose it, every client must be re-enrolled with new keys. Add the volume to the routine from our Restic backup guide and test a restore once. Treat the backup as sensitive data, because it contains private keys.

Pair it with your homelab DNS

A VPN becomes more useful when your own DNS server sits behind it. If you run AdGuard Home, set the wg-easy default DNS to its LAN address. Every tunneled device then gets ad blocking and your internal hostnames wherever it is. The wg-easy docs include an AdGuard Home tutorial for running both together.

For general hardening of anything exposed to the internet, including this single UDP port, see our homelab security rules.

FAQ

Is WireGuard faster than OpenVPN?

Usually, yes. WireGuard runs in the kernel and uses a smaller, modern protocol, so throughput is typically higher and connections recover faster when a phone changes networks. On a small VPS, the server’s network link is more likely to be the bottleneck than the VPN.

Can I run wg-easy behind CGNAT?

Not directly. Clients must reach UDP 51820 on a public address. If your ISP uses carrier-grade NAT, run wg-easy on a cheap VPS, or use a mesh tool such as Tailscale, which handles NAT traversal for you.

Why not use the latest image tag?

The wg-easy docs say latest points to the v14 release and should be avoided. Pinning to 15 gives you new features and fixes within the current major version without unexpected breaking changes.

Do I need a domain name?

No. A static public IP address works as the client host. A domain makes it easier to move the server later and is required if you want a trusted HTTPS certificate for the admin panel.

How many clients can it handle?

Many more than a household needs. Each client is a key pair and a small amount of state. In practice, bandwidth and CPU on the host set the limit, not wg-easy.

Wrapping up

With one Compose file and one open UDP port, you have a private VPN you control: phones and laptops are protected on public Wi-Fi, your homelab is reachable without exposing each service, and adding a device takes one QR scan. Pin the major version, keep the admin panel off the open internet, and back up the etc_wireguard volume.