Simple Web based configuration generator for WireGuard. Demo:

Wg Gen Web

Simple Web based configuration generator for WireGuard

Simple Web based configuration generator for WireGuard.

Go Report Card License: WTFPL Discord Build docker images via buildx GitHub last commit Docker Pulls GitHub go.mod Go version GitHub code size in bytes

Why another one ?

All WireGuard UI implementations are trying to manage the service by applying configurations and creating network rules. This implementation only generates configuration and its up to you to create network rules and apply configuration to WireGuard. For example by monitoring generated directory with inotifywait.

The goal is to run Wg Gen Web in a container and WireGuard on host system.

Features

  • Self-hosted and web based
  • Automatically select IP from the netowrk pool assigned to client
  • QR-Code for convenient mobile client configuration
  • Sent email to client with QR-code and client config
  • Enable / Disable client
  • Generation of wg0.conf after any modification
  • IPv6 ready
  • User authentication (Oauth2 OIDC)
  • Dockerized
  • Pretty cool look

Screenshot

Running

Docker

The easiest way to run Wg Gen Web is using the container image

docker run --rm -it -v /tmp/wireguard:/data -p 8080:8080 -e "WG_CONF_DIR=/data" vx3r/wg-gen-web:latest

Docker compose snippet, used for demo server, wg-json-api service is optional

version: '3.6'
services:
  wg-gen-web-demo:
    image: vx3r/wg-gen-web:latest
    container_name: wg-gen-web-demo
    restart: unless-stopped
    expose:
      - "8080/tcp"
    environment:
      - WG_CONF_DIR=/data
      - WG_INTERFACE_NAME=wg0.conf
      - SMTP_HOST=smtp.gmail.com
      - SMTP_PORT=587
      - [email protected]
      - SMTP_PASSWORD=******************
      - SMTP_FROM=Wg Gen Web <[email protected]>
      - OAUTH2_PROVIDER_NAME=github
      - OAUTH2_PROVIDER=https://github.com
      - OAUTH2_CLIENT_ID=******************
      - OAUTH2_CLIENT_SECRET=******************
      - OAUTH2_REDIRECT_URL=https://wg-gen-web-demo.127-0-0-1.fr
    volumes:
      - /etc/wireguard:/data
  wg-json-api:
    image: james/wg-api:latest
    container_name: wg-json-api
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    network_mode: "host"
    command: wg-api --device wg0 --listen <API_LISTEN_IP>:8182

Please note that mapping /etc/wireguard to /data inside the docker, will erase your host's current configuration. If needed, please make sure to backup your files from /etc/wireguard.

A workaround would be to change the WG_INTERFACE_NAME to something different, as it will create a new interface (wg-auto.conf for example), note that if you do so, you will have to adapt your daemon accordingly.

To get the value for <API_LISTEN_IP> take a look at the WireGuard Status Display section. If the status display should be disabled, remove the whole service from the docker-compose file or use 127.0.0.1 as <API_LISTEN_IP>.

Directly without docker

Fill free to download latest artifacts from my GitLab server:

Put everything in one directory, create .env file with all configurations and run the backend.

Automatically apply changes to WireGuard

Using systemd

Using systemd.path monitor for directory changes see systemd doc

# /etc/systemd/system/wg-gen-web.path
[Unit]
Description=Watch /etc/wireguard for changes

[Path]
PathModified=/etc/wireguard

[Install]
WantedBy=multi-user.target

This .path will activate unit file with the same name

# /etc/systemd/system/wg-gen-web.service
[Unit]
Description=Restart WireGuard
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart [email protected]

[Install]
WantedBy=multi-user.target

Which will restart WireGuard service

Using inotifywait

For any other init system, create a daemon running this script

#!/bin/sh
while inotifywait -e modify -e create /etc/wireguard; do
  wg-quick down wg0
  wg-quick up wg0
done

How to use with existing WireGuard configuration

After first run Wg Gen Web will create server.json in data directory with all server informations.

Feel free to modify this file in order to use your existing keys

What is out of scope

  • Generation or application of any iptables or nftables rules
  • Application of configuration to WireGuard by Wg Gen Web itself

Authentication

Wg Gen Web can use Oauth2 OpenID Connect provider to authenticate users. Currently there are 4 implementations:

  • fake not a real implementation, use this if you don't want to authenticate your clients.

Add the environment variable:

OAUTH2_PROVIDER_NAME=fake
  • github in order to use GitHub as Oauth2 provider.

Add the environment variable:

OAUTH2_PROVIDER_NAME=github
OAUTH2_PROVIDER=https://github.com
OAUTH2_CLIENT_ID=********************
OAUTH2_CLIENT_SECRET=********************
OAUTH2_REDIRECT_URL=https://wg-gen-web-demo.127-0-0-1.fr
  • google in order to use Google as Oauth2 provider. Not yet implemented
help wanted
  • oauth2oidc in order to use RFC compliant Oauth2 OpenId Connect provider.

Add the environment variable:

OAUTH2_PROVIDER_NAME=oauth2oidc
OAUTH2_PROVIDER=https://gitlab.com
OAUTH2_CLIENT_ID=********************
OAUTH2_CLIENT_SECRET=********************
OAUTH2_REDIRECT_URL=https://wg-gen-web-demo.127-0-0-1.fr

Wg Gen Web will only access your profile to get email address and your name, no other unnecessary scopes will be requested.

WireGuard Status Display

Wg Gen Web integrates a WireGuard API implementation to display client stats. In order to enable the Status API integration, the following settings need to be configured:

# https://github.com/jamescun/wg-api integration, user and password (basic auth) are optional
WG_STATS_API=http://<API_LISTEN_IP>:8182
WG_STATS_API_USER=
WG_STATS_API_PASS=

To setup the WireGuard API take a look at https://github.com/jamescun/wg-api/blob/master/README.md, or simply use the provided docker-compose file from above.

API_LISTEN_IP

Due to the fact that the wg-api container operates on the host network, the wg-gen-web container cannot directly talk to the API. Thus the docker-host gateway IP of the wg-gen-web container has to be used. If the default bridge network (docker0) is used, this IP should be 172.17.0.1. If a custom network is used, you can find the gateway IP by inspecting the output of:

docker network inspect <network name>

Use the IP address found for Gateway as the API_LISTEN_IP.

Please feel free to test and report any bugs.

Need Help

  • Join us on Discord
  • Create an issue

Development

Backend

From the top level directory run

$ go run main.go

Frontend

Inside another terminal session navigate into the ui folder

$ cd ui

Install required dependencies

$ npm install

Set the base url for the api

$ export VUE_APP_API_BASE_URL=http://localhost:8080/api/v1.0

Start the development server. It will rebuild and reload the site once you make a change to the source code.

$ npm run serve

Now you can access the site from a webbrowser with the url http://localhost:8081.

Application stack

License

Comments
  • Suggestion , CLIENTS UI as Tabular list.

    Suggestion , CLIENTS UI as Tabular list.

    Hello, I like your idea and project, thanks for the good work.

    A suggestion towards the CLIENTS UI, i think it would be more useful to have the CLIENTS TAB as a Tabular list rather than each CLIENT being shown in Card form with the QR codealongside.

    This is because the CLIENT and SERVER Tabs would normally be administered by an administrator not by the actual Client user. This way realestate screenspace can be better utilized , also not being the actual user there is no direct need for the QR code upfront on screen, a link should suffice (or a mouseover event).

    just a thought, sadly i'm not a programmer to help out.

    as said before good work ;)

    Best Regards, Aniston

  • cant login after vx3r/wg-gen-web:f90124af build

    cant login after vx3r/wg-gen-web:f90124af build

    in browser console:

    Error: "ApiService: TypeError: e is undefined"
        get api.service.js:14
    App.vue:69
    server report oauth2 is disabled, fake exchange auth.js:50:18
    Updating authStatus from  to disabled App.vue:91
    Updating authStatus from disabled to success App.vue:91
    
  • Wanna work together and add this to my installer?

    Wanna work together and add this to my installer?

    Hey I have a wireguard installer with over 2500 clones and 300 stars and I think this would be an amazing side thing to add to that so instead of a CLI only users would be able to use a GUI too.

    What do you think about it??

  • wg0.conf not updating

    wg0.conf not updating

    Hi,

    Great project - really like the flexibility of the UI which I haven't seen in any other gui's for wireguard yet. Super easy and the e-mail function works great!

    I did discover something that may be due to how I setup my docker container, where the wg0.conf isn't updated but instead a wg0 file is being generated alongside.

    In other words it seems like I need to the following to get new clients up and running:

    mv wg0 wg0.conf
    wg-quick down wg0; wg-quick up wg0
    
    

    My questions is really if this is expected or if I should have done something else with the setup?

  • No connection between wg-gen-web and wg-api

    No connection between wg-gen-web and wg-api

    Running this docker compose file:

    services:
      wg-gen-web:
        image: vx3r/wg-gen-web:latest
        container_name: wg-gen-web
        restart: unless-stopped
        ports:
          - "8080:8080"
        environment:
          - WG_CONF_DIR=/data
          - WG_INTERFACE_NAME=wg0.conf
          - SMTP_HOST=smtp.gmail.com
          - SMTP_PORT=587
          - SMTP_USERNAME=xx
          - SMTP_PASSWORD=xx
          - SMTP_FROM=xx
          - OAUTH2_PROVIDER_NAME=fake
          - WG_STATS_API=http://172.17.0.1:8182
        volumes:
          - /etc/wireguard:/data
      wg-api:
        image: james/wg-api:latest
        container_name: wg-json-api
        restart: unless-stopped
        ports:
          - "8182:8182"
        cap_add:
          - NET_ADMIN
        network_mode: "host"
        command: wg-api --device=wg0 --listen=localhost:8182
    

    wg-gen-web works and I can request the wg-api succesfully:

    curl http://172.17.0.1:8182 -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "GetDeviceInfo", "params": {}}' {"jsonrpc":"2.0","result":{"device":{"name":"wg0","type":"Linux kernel","public_key":"thekeyhasbeenredacted=","listen_port":51820,"num_peers":1}},"id":null}

    on the wg-gen-web status page this message is shown:

    Error: 500 - Internal Server Error: Post "http://172.17.0.1:8182": dial tcp 172.17.0.1:8182: connect: connection refused

    Since wg-api is running in Host mode and wg-gen-web is not, could this be the issue, or is there another solution?

    pinging @h44z :)

  • TLS support for sending email

    TLS support for sending email

    Please add TLS support for SMTP, as most services mandate TLS connection.

    d.TLSConfig = &tls.Config{InsecureSkipVerify: true} (or use env for setup)

    Thanks,

  • Ubuntu host, installed Wireguard + tools, wg-gen-web not working

    Ubuntu host, installed Wireguard + tools, wg-gen-web not working

    I must be missing a step. I used to have PiVPN (Wireguard) installed and created configs with that, everything worked. Now I uninstalled PiVPN, uninstalled wireguard (which also removes wireguard-tools), deleted /etc/wireguard.

    After a reboot,, I do sudo apt install wireguard which also installs tools automatically. Then run my docker-compose up -d:

      vpn-server-ui:
        image: vx3r/wg-gen-web:latest
        container_name: vpn-server-ui
        restart: always
        networks:
          - management
        environment:
          WG_CONF_DIR: /data
          WG_INTERFACE_NAME: wg0.conf
          SMTP_HOST: $SMTP
          SMTP_PORT: 587
          SMTP_USERNAME: $SMTPUSER
          SMTP_PASSWORD: $SMTPPASS
          SMTP_FROM: $EMAIL
        volumes:
          - /etc/wireguard:/data
        ports:
          - "5100:8080"
    

    I can access the webui on port 5100 just fine.

    Server configuration: Public Key: .... Listen port: 51822 Server interface addresses: 10.6.6.1/24

    Client Configuration: Public endpoint: mydomain.cloud:51822 DNS server: 1.1.1.1 Default allowed: 0.0.0/0, ::/0 No values for MTU and keepalive

    I create a client:

    email address: my address Addresses: 10.6.6.2/32 Allowed IP addresses: 0.0.0/0, ::/0 No values for MTU and keepalive

    After saving, I do: sudo systemctl start [email protected] Reload doesn't work because wg hasn't been started before.

    Then I scan the QR code with my Android phone and try to connect: nothing. 0 bytes received, some bytes send.

    What am I missing?

    EDIT: I can access my server LAN IP! Just no internet. Perhaps a DNS issue? But I simply used 1.1.1.1 for testing.. would expect that to work.

  • Error while trying to display stats

    Error while trying to display stats

    While trying to display stats, I get the following error:

    Error: 500 - Internal Server Error: Post "http://172.17.0.1:8182": dial tcp 172.17.0.1:8182: i/o timeout (Client.Timeout exceeded while awaiting headers)

    If I try and do a curl from the host, it reruns correctly:

    ben@vpnserver:/opt/wg-ui$ curl http://172.17.0.1:8182 -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "GetDeviceInfo", "params": {}}'
    {"jsonrpc":"2.0","result":{"device":{"name":"wg0","type":"Linux kernel","public_key":"zzzzzzzzzzzzzzzzzzzzzzz=","listen_port":12345,"num_peers":4}},"id":null}
    

    Here is my docker-compose.json:

    version: '3.6'
    services:
      wg-ui:
        image: vx3r/wg-gen-web:latest
        container_name: wg-ui
        restart: unless-stopped
        ports:
          - "80:8080"
        environment:
          - WG_CONF_DIR=/data
          - WG_INTERFACE_NAME=wg0.conf
          - OAUTH2_PROVIDER_NAME=fake
          - WG_STATS_API=http://172.17.0.1:8182
        volumes:
          - /etc/wireguard:/data
      wg-json-api:
        image: james/wg-api:latest
        container_name: wg-json-api
        restart: unless-stopped
        cap_add:
          - NET_ADMIN
        network_mode: "host"
        command: wg-api --device wg0 --listen 172.17.0.1:8182
    
    
  • Wg api integration

    Wg api integration

    A integration for https://github.com/jamescun/wg-api:

    • display WireGuard interface details (from the GetDeviceInfo request)
    • display WireGuard client status (from the ListPeers request)

    This is how it looks like: wg_status

  • Simple page refresh updates wg0.conf

    Simple page refresh updates wg0.conf

    Hi, I installed this service successfully and configured systemd to monitor /etc/wireguard to reload wireguard configuration as per your instructions in the Readme. But it seems that on every simple GET of the web ui, without changing any setting wg0.conf gets updated and therefore wireguard restarted. Is this the expected behavior? Isn't this a problem because of service interruption? Thanks for this nice gui!

  • I can not create a user with the latest version (f90124a)

    I can not create a user with the latest version (f90124a)

    Latest docker release - Version: f90124a I can not create a user in UI, Submit button is not pressed

    downgraded to Version: 867d79e - fix problem several servers are affected

  • Adds Support For Mesh Peers

    Adds Support For Mesh Peers

    Adds support for mesh peers by adding fields to the clients. Support for "VPN" clients was not added -- there were no preUp, preDown fields added.

  • Added simplified use of a secure connection for public networks in docker compose configuration

    Added simplified use of a secure connection for public networks in docker compose configuration

    Added simplified use of a secure connection for public networks in docker compose configuration

    VIRTUAL_HOST, LETSENCRYPT_HOST = enter domain name DEFAULT_EMAIL = your email address to receive notifications from Let's Encrypt

  • Impossible to disconnect / add / revoke users from the server without restarting it. Statistics on users are also not synchronized without restarting the server

    Impossible to disconnect / add / revoke users from the server without restarting it. Statistics on users are also not synchronized without restarting the server

    1. It is not possible to add a new user / disconnect a user / remove a user without restarting the server. When adding / deactivating / deleting, only the web interface works, but the apology does not take effect. Those to the disconnected / removed peer can still be connected, but to the newly added peer, on the contrary, cannot be connected. It only helps to restart the server via guard with the command systemctl restart wg-quick@wg0

    2. User statistics are not synchronized with the user list apology.

    How can this problem be solved?

  • Error: 500 - Internal Server Error:

    Error: 500 - Internal Server Error:

    Hi !

    This is a very good project!This is a very good project. I can't send email right now.

    1. logs:
    • wg-gen-web | 2022-04-04T14:56:41.147946940Z time="2022-04-04T14:56:41Z" level=error msg="failed to send email to client" err="534 5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt\n5.7.14 23hmA_oclTIUbFePKukcRnydT7YNqsd6qSRIb7jw5Q82HhO5obeOgvyl9KxB4UdB-yN7_\n5.7.14 M1lrtLL1IMWdLm7dA6dhgSeYPsfO0tdGUlU2NmY33fMoz-zGVTwjWSZmuuFLqOoM>\n5.7.14 Please log in via your web browser and then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 g5-20020a056a0023c500b004fae15ab86dsm12239530pfc.52 - gsmtp"

    • wg-gen-web | 2022-04-04T14:56:41.148369402Z [GIN] 2022/04/04 - 14:56:41 | 500 | 1.311139946s | 103.172.53.140 | GET "/api/v1.0/client/eac1702e-4f37-4896-9fda-f186c416d408/email"

    • wg-gen-web | 2022-04-04T14:58:43.603979494Z time="2022-04-04T14:58:43Z" level=error msg="failed to send email to client" err="534 5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu\n5.7.14 zED9hKRRquRgPGWeSfWSp0cOJdcagMexvGYQbNSZcYWmjUBJajwdXkQJQxO2apfQmYA53\n5.7.14 1DSVPV40au8uaVeMem4mvi1RNLkfO1OnyhMYjeF-VOrvtbUUz86ooLAr4Ks1NGRA>\n5.7.14 Please log in via your web browser and then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 c4-20020a17090a4d0400b001ca5cf3271csm7870237pjg.14 - gsmtp"

    • wg-gen-web | 2022-04-04T14:58:43.604564499Z [GIN] 2022/04/04 - 14:58:43 | 500 | 1.480325319s | 103.172.53.140 | GET "/api/v1.0/client/eac1702e-4f37-4896-9fda-f186c416d408/email"

    1. cocker-compose.yml

    version: '3.6' services: wg-gen-web: image: vx3r/wg-gen-web:latest container_name: wg-gen-web restart: always expose: - "8080/tcp" ports: - "127.0.0.1:8080:8080" environment: - WG_CONF_DIR=/data - WG_INTERFACE_NAME=wg0.conf - WG_STATS_API=http://192.168.201.1:8182 - SMTP_HOST=smtp.gmail.com - SMTP_PORT=587 - SMTP_USERNAME=***@gmail.com - SMTP_PASSWORD=*** - SMTP_FROM=your wireguard info ***@gmail.com - OAUTH2_PROVIDER_NAME=github - OAUTH2_PROVIDER=https://github.com - OAUTH2_CLIENT_ID=*** - OAUTH2_CLIENT_SECRET=*** - OAUTH2_REDIRECT_URL=*** volumes: - /etc/wireguard:/data wg-json-api: image: james/wg-api:latest container_name: wg-json-api restart: always cap_add: - NET_ADMIN network_mode: "host" command: wg-api --device wg0 --listen 192.168.201.1:8182 networks: default: name: docker_wg_net1 driver: bridge ipam: driver: default config: - subnet: "192.168.201.0/24"

    1. I did proxying and 443 handling using nginx.
A flexible configuration manager for Wireguard networks
A flexible configuration manager for Wireguard networks

Drago A flexible configuration manager for WireGuard networks Drago is a flexible configuration manager for WireGuard networks which is designed to ma

Jan 7, 2023
Connect your devices into a single private WireGuard®-based mesh network.

Wiretrustee A WireGuard®-based mesh network that connects your devices into a single private network. Why using Wiretrustee? Connect multiple devices

Dec 31, 2022
A fork of the simple WireGuard VPN server GUI community maintained
A fork of the simple WireGuard VPN server GUI community maintained

Subspace - A simple WireGuard VPN server GUI Subspace - A simple WireGuard VPN server GUI Slack Screenshots Features Contributing Setup 1. Get a serve

Dec 25, 2022
Traefik config validator: a CLI tool to (syntactically) validate your Traefik configuration filesTraefik config validator: a CLI tool to (syntactically) validate your Traefik configuration files
Traefik config validator: a CLI tool to (syntactically) validate your Traefik configuration filesTraefik config validator: a CLI tool to (syntactically) validate your Traefik configuration files

Traefik Config Validator Note This is currently pre-release software. traefik-config-validator is a CLI tool to (syntactically) validate your Traefik

Dec 16, 2021
The easiest, most secure way to use WireGuard and 2FA.

This repository contains all the open source Tailscale client code and the tailscaled daemon and tailscale CLI tool. The tailscaled daemon runs primarily on Linux; it also works to varying degrees on FreeBSD, OpenBSD, Darwin, and Windows.

Jan 8, 2023
An userspace SORACOM Arc client powered by wireguard-go

soratun An easy-to-use, userspace SORACOM Arc client powered by wireguard-go. For deploying and scaling Linux servers/Raspberry Pi devices working wit

Jun 2, 2022
A Wireguard VPN Server Manager and API to add and remove clients

Wireguard Manager And API A manager and API to add, remove clients as well as other features such as an auto reapplier which deletes and adds back a c

Dec 22, 2022
Layer2 version of wireguard with Floyd Warshall implement in go.

Etherguard 中文版README A Full Mesh Layer2 VPN based on wireguard-go OSPF can find best route based on it's cost. But sometimes the lentancy are differen

Dec 29, 2022
Magic util that "bridges" Wireguard with OpenVPN without a TUN/TAP interface

wg-ovpn Magic util that "bridges" Wireguard with OpenVPN without a TUN/TAP interface Warning: really ugly and unstable code! Building Obtain latest so

Sep 27, 2022
Mount your podman container into WireGuard networks on spawn

wg-pod A tool to quickly join your podman container/pod into a WireGuard network. Explanation wg-pod wires up the tools ip,route,wg and podman. It cre

Aug 14, 2022
Go Implementation of WireGuard

Go Implementation of WireGuard

Jan 2, 2023
A HTTP proxy server tunnelling through wireguard

wg-http-proxy This project hacks together the excellent https://github.com/elazarl/goproxy and https://git.zx2c4.com/wireguard-go into an HTTP proxy s

Dec 30, 2022
NAT puncher for Wireguard mesh networking.

natpunch-go This is a NAT hole punching tool designed for creating Wireguard mesh networks. It was inspired by Tailscale and informed by this example.

Dec 12, 2022
generate Wireguard keypairs with a given prefix string

wireguard-vanity-address Generate Wireguard keypairs with a given prefix string. The Wireguard VPN uses Curve25519 keypairs, and displays the Base64-e

Nov 9, 2022
udppunch hole for wireguard

udppunch udp punch for wireguard, inspired by natpunch-go usage server side ./punch-server-linux-amd64 -port 19993 client side make sure wireguard is

Nov 24, 2022
A standalone Web Server developed with the standard http library, suport reverse proxy & flexible configuration
A standalone Web Server developed with the standard http library, suport reverse proxy & flexible configuration

paddy 简介 paddy是一款单进程的独立运行的web server,基于golang的标准库net/http实现。 paddy提供以下功能: 直接配置http响应 目录文件服务器 proxy_pass代理 http反向代理 支持请求和响应插件 部署 编译 $ go build ./main/p

Oct 18, 2022
protoc-gen-grpc-gateway-ts is a Typescript client generator for the grpc-gateway project. It generates idiomatic Typescript clients that connect the web frontend and golang backend fronted by grpc-gateway.

protoc-gen-grpc-gateway-ts protoc-gen-grpc-gateway-ts is a Typescript client generator for the grpc-gateway project. It generates idiomatic Typescript

Dec 19, 2022
A simple Go library to toggle on and off pac(proxy auto configuration) for Windows, MacOS and Linux

pac pac is a simple Go library to toggle on and off pac(proxy auto configuration

Dec 26, 2021
The hotwire demo chat written in Golang

Hotwire Go Example This is a recreation of the Hotwire Rails Demo Chat with a Go backend. See the Hotwire docs for more information about Hotwire. Qui

Jan 4, 2023