wghttp is a zero-log, lightweight, and opinionated HTTP server for managing WireGuard devices and peers.
It’s particularly useful when you need to control your WireGuard setup remotely.
It also simplifies the process of adding devices or peers — allowing you to do it with a single HTTP call.
wghttp saves time, especially when adding new peers to your VPN server without needing to SSH in.
- RESTful HTTP API for managing WireGuard interfaces and peers
- Runs on Unix domain socket by default (
/var/run/wghttp.sock) - Can be configured to run over TCP (
--tcp ip:port) - Swagger UI available at
/swagger-ui/for API exploration
cargo build --release
./target/release/wghttp --helpsudo ./wghttpsudo ./wghttp --tcp 127.0.0.1:8080Note: Unix domain socket is preferred since it delegates authentication to the system. Users cannot send curl requests without
sudo.
wghttp interacts with networking interfaces and requires elevated privileges.
- The application must be run with
sudounless theCAP_NET_ADMINcapability is explicitly granted. - Granting
CAP_NET_ADMINis not recommended due to potential security implications.
sudo setcap cap_net_admin+ep ./target/release/wghttpTo secure wghttp behind HTTPS and add basic authentication, you can use Caddy as a reverse proxy.
Below is an example Caddyfile that:
- Listens on port 443 with HTTPS
- Applies HTTP Basic Auth
- Uses a self-signed TLS certificate
- Proxies traffic to
wghttpover a Unix domain socket
https://[::]:443, https://:443 {
reverse_proxy unix//var/run/wghttp.sock
basic_auth {
your_username $2a$14$zBNAL8oUW/m3vpTIjm2ts.M64u2JKRvZJkd2bw/kKDSV3tniHWPuW
}
tls /path/to/self-signed.crt /path/to/self-signed.key
}You can generate a bcrypt hash for your password using
caddy hash-passwordinteractive command.
To explore the API and send test requests:
http://localhost/swagger-ui/
The interface uses OpenAPI 3.0 specification.
Some tests require access to system commands:
ipcommand (viaiproute2package)wgcommand (viawireguard-toolspackage)
| Distribution | Install Command |
|---|---|
| Arch Linux | sudo pacman -S iproute2 wireguard-tools |
| Ubuntu/Debian | sudo apt install iproute2 wireguard-tools |
| Fedora | sudo dnf install iproute wireguard-tools |
cargo test -p wghttpsudo -E $(which cargo) test -p netdev
netdevtests depend onip
sudo -E $(which cargo) test -p wgshim -- --test-threads 1
wgshimtests depend on bothipandwgcommands.
This project includes components from the WireGuard embedding library (wireguard.c and wireguard.h), which are licensed under the LGPL-2.1+ license. All other parts of this project are licensed under the MIT License.
See LICENSE and individual source files for more information.