New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/ngoduykhanh/wireguard-ui

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/ngoduykhanh/wireguard-ui

  • v0.6.1
  • Source
  • Go
  • Socket score

Version published
Created
Source

wireguard-ui

A web user interface to manage your WireGuard setup.

Features

  • Friendly UI
  • Authentication
  • Manage extra client information (name, email, etc.)
  • Retrieve client config using QR code / file / email / Telegram

wireguard-ui 0.3.7

Run WireGuard-UI

⚠️The default username and password are admin. Please change it to secure your setup.

Using binary file

Download the binary file from the release page and run it directly on the host machine

./wireguard-ui

Using docker compose

The examples/docker-compose folder contains example docker-compose files. Choose the example which fits you the most, adjust the configuration for your needs, then run it like below:

docker-compose up

Environment Variables

VariableDescriptionDefault
BASE_PATHSet this variable if you run wireguard-ui under a subpath of your reverse proxy virtual host (e.g. /wireguard)N/A
BIND_ADDRESSThe addresses that can access to the web interface and the port, use unix:///abspath/to/file.socket for unix domain socket.0.0.0.0:80
SESSION_SECRETThe secret key used to encrypt the session cookies. Set this to a random valueN/A
SESSION_SECRET_FILEOptional filepath for the secret key used to encrypt the session cookies. Leave SESSION_SECRET blank to take effectN/A
SESSION_MAX_DURATIONMax time in days a remembered session is refreshed and valid. Non-refreshed session is valid for 7 days max, regardless of this setting.90
SUBNET_RANGESThe list of address subdivision ranges. Format: SR Name:10.0.1.0/24; SR2:10.0.2.0/24,10.0.3.0/24 Each CIDR must be inside one of the server interfaces.N/A
WGUI_USERNAMEThe username for the login page. Used for db initialization onlyadmin
WGUI_PASSWORDThe password for the user on the login page. Will be hashed automatically. Used for db initialization onlyadmin
WGUI_PASSWORD_FILEOptional filepath for the user login password. Will be hashed automatically. Used for db initialization only. Leave WGUI_PASSWORD blank to take effectN/A
WGUI_PASSWORD_HASHThe password hash for the user on the login page. (alternative to WGUI_PASSWORD). Used for db initialization onlyN/A
WGUI_PASSWORD_HASH_FILEOptional filepath for the user login password hash. (alternative to WGUI_PASSWORD_FILE). Used for db initialization only. Leave WGUI_PASSWORD_HASH blank to take effectN/A
WGUI_ENDPOINT_ADDRESSThe default endpoint address used in global settings where clients should connect to. The endpoint can contain a port as well, useful when you are listening internally on the WGUI_SERVER_LISTEN_PORT port, but you forward on another port (ex 9000). Ex: myvpn.dyndns.com:9000Resolved to your public ip address
WGUI_FAVICON_FILE_PATHThe file path used as website faviconEmbedded WireGuard logo
WGUI_DNSThe default DNS servers (comma-separated-list) used in the global settings1.1.1.1
WGUI_MTUThe default MTU used in global settings1450
WGUI_PERSISTENT_KEEPALIVEThe default persistent keepalive for WireGuard in global settings15
WGUI_FIREWALL_MARKThe default WireGuard firewall mark0xca6c (51820)
WGUI_TABLEThe default WireGuard table value settingsauto
WGUI_CONFIG_FILE_PATHThe default WireGuard config file path used in global settings/etc/wireguard/wg0.conf
WGUI_LOG_LEVELThe default log level. Possible values: DEBUG, INFO, WARN, ERROR, OFFINFO
WG_CONF_TEMPLATEThe custom wg.conf config file template. Please refer to our default templateN/A
EMAIL_FROM_ADDRESSThe sender email addressN/A
EMAIL_FROM_NAMEThe sender nameWireGuard UI
SENDGRID_API_KEYThe SendGrid api keyN/A
SENDGRID_API_KEY_FILEOptional filepath for the SendGrid api key. Leave SENDGRID_API_KEY blank to take effectN/A
SMTP_HOSTNAMEThe SMTP IP address or hostname127.0.0.1
SMTP_PORTThe SMTP port25
SMTP_USERNAMEThe SMTP usernameN/A
SMTP_PASSWORDThe SMTP user passwordN/A
SMTP_PASSWORD_FILEOptional filepath for the SMTP user password. Leave SMTP_PASSWORD blank to take effectN/A
SMTP_AUTH_TYPEThe SMTP authentication type. Possible values: PLAIN, LOGIN, NONENONE
SMTP_ENCRYPTIONThe encryption method. Possible values: NONE, SSL, SSLTLS, TLS, STARTTLSSTARTTLS
SMTP_HELOHostname to use for the HELO message. smtp-relay.gmail.com needs this set to anything but localhostlocalhost
TELEGRAM_TOKENTelegram bot token for distributing configs to clientsN/A
TELEGRAM_ALLOW_CONF_REQUESTAllow users to get configs from the bot by sending a messagefalse
TELEGRAM_FLOOD_WAITTime in minutes before the next conf request is processed60

Defaults for server configuration

These environment variables are used to control the default server settings used when initializing the database.

VariableDescriptionDefault
WGUI_SERVER_INTERFACE_ADDRESSESThe default interface addresses (comma-separated-list) for the WireGuard server configuration10.252.1.0/24
WGUI_SERVER_LISTEN_PORTThe default server listen port51820
WGUI_SERVER_POST_UP_SCRIPTThe default server post-up scriptN/A
WGUI_SERVER_POST_DOWN_SCRIPTThe default server post-down scriptN/A

Defaults for new clients

These environment variables are used to set the defaults used in New Client dialog.

VariableDescriptionDefault
WGUI_DEFAULT_CLIENT_ALLOWED_IPSComma-separated-list of CIDRs for the Allowed IPs field. (default )0.0.0.0/0
WGUI_DEFAULT_CLIENT_EXTRA_ALLOWED_IPSComma-separated-list of CIDRs for the Extra Allowed IPs field. (default empty)N/A
WGUI_DEFAULT_CLIENT_USE_SERVER_DNSBoolean value [0, f, F, false, False, FALSE, 1, t, T, true, True, TRUE]true
WGUI_DEFAULT_CLIENT_ENABLE_AFTER_CREATIONBoolean value [0, f, F, false, False, FALSE, 1, t, T, true, True, TRUE]true

Docker only

These environment variables only apply to the docker container.

VariableDescriptionDefault
WGUI_MANAGE_STARTStart/stop WireGuard when the container is started/stoppedfalse
WGUI_MANAGE_RESTARTAuto restart WireGuard when we Apply Config changes in the UIfalse

Auto restart WireGuard daemon

WireGuard-UI only takes care of configuration generation. You can use systemd to watch for the changes and restart the service. Following is an example:

Using systemd

Create /etc/systemd/system/wgui.service

cd /etc/systemd/system/
cat << EOF > wgui.service
[Unit]
Description=Restart WireGuard
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service

[Install]
RequiredBy=wgui.path
EOF

Create /etc/systemd/system/wgui.path

cd /etc/systemd/system/
cat << EOF > wgui.path
[Unit]
Description=Watch /etc/wireguard/wg0.conf for changes

[Path]
PathModified=/etc/wireguard/wg0.conf

[Install]
WantedBy=multi-user.target
EOF

Apply it

systemctl enable wgui.{path,service}
systemctl start wgui.{path,service}

Using openrc

Create /usr/local/bin/wgui file and make it executable

cd /usr/local/bin/
cat << EOF > wgui
#!/bin/sh
wg-quick down wg0
wg-quick up wg0
EOF
chmod +x wgui

Create /etc/init.d/wgui file and make it executable

cd /etc/init.d/
cat << EOF > wgui
#!/sbin/openrc-run

command=/sbin/inotifyd
command_args="/usr/local/bin/wgui /etc/wireguard/wg0.conf:w"
pidfile=/run/${RC_SVCNAME}.pid
command_background=yes
EOF
chmod +x wgui

Apply it

rc-service wgui start
rc-update add wgui default

Using Docker

Set WGUI_MANAGE_RESTART=true to manage Wireguard interface restarts. Using WGUI_MANAGE_START=true can also replace the function of wg-quick@wg0 service, to start Wireguard at boot, by running the container with restart: unless-stopped. These settings can also pick up changes to Wireguard Config File Path, after restarting the container. Please make sure you have --cap-add=NET_ADMIN in your container config to make this feature work.

Build

Build docker image

Go to the project root directory and run the following command:

docker build --build-arg=GIT_COMMIT=$(git rev-parse --short HEAD) -t wireguard-ui .

or

docker compose build --build-arg=GIT_COMMIT=$(git rev-parse --short HEAD)

:information_source: A container image is available on Docker Hub which you can pull and use

docker pull ngoduykhanh/wireguard-ui

Build binary file

Prepare the assets directory

./prepare_assets.sh

Then build your executable

go build -o wireguard-ui

License

MIT. See LICENSE.

Support

If you like the project and want to support it, you can buy me a coffee

Buy Me A Coffee

FAQs

Package last updated on 07 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc