wireguard-ui/README.md

154 lines
3.1 KiB
Markdown
Raw Normal View History

2020-05-21 18:33:10 +02:00
![](https://github.com/ngoduykhanh/wireguard-ui/workflows/wireguard-ui%20build%20release/badge.svg)
2020-05-21 18:33:46 +02:00
# wireguard-ui
2020-04-25 06:13:29 +02:00
A web user interface to manage your WireGuard setup.
## Features
- Friendly UI
- Authentication
- Manage extra client's information (name, email, etc)
- Retrieve configs using QR code / file
## Run WireGuard-UI
Default username and password are `admin`.
### Using docker compose
You can take a look at this example of [docker-compose.yml](https://github.com/ngoduykhanh/wireguard-ui/blob/master/docker-compose.yaml). Please adjust volume mount points to work with your setup. Then run it like below:
2020-04-25 06:13:29 +02:00
```
docker-compose up
```
### Environment Variables
Set the `SESSION_SECRET` environment variable to a random value.
In order to sent the wireguard configuration to clients via email (using sendgrid api) set the following environment variables
```
SENDGRID_API_KEY: Your sendgrid api key
EMAIL_FROM: the email address you registered on sendgrid
EMAIL_FROM_NAME: the sender's email address
```
2020-04-25 06:13:29 +02:00
### Using binary file
Download the binary file from the release and run it with command:
```
./wireguard-ui
```
2020-04-25 06:16:20 +02:00
2020-04-25 06:13:29 +02:00
## 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:
### systemd
2020-04-25 06:13:29 +02:00
Create /etc/systemd/system/wgui.service
```
[Unit]
Description=Restart WireGuard
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service
2021-08-05 19:46:11 +02:00
[Install]
RequiredBy=wgui.path
2020-04-25 06:13:29 +02:00
```
Create /etc/systemd/system/wgui.path
```
[Unit]
Description=Watch /etc/wireguard/wg0.conf for changes
[Path]
PathModified=/etc/wireguard/wg0.conf
[Install]
WantedBy=multi-user.target
```
Apply it
2020-04-25 06:13:29 +02:00
```
systemctl enable wgui.{path,service}
systemctl start wgui.{path,service}
```
### openrc
Create and `chmod +x` /usr/local/bin/wgui
```
#!/bin/sh
wg-quick down wg0
wg-quick up wg0
```
Create and `chmod +x` /etc/init.d/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
```
Apply it
```
rc-service wgui start
rc-update add wgui default
```
## Build
### Build docker image
Go to the project root directory and run the following command:
```
docker build -t wireguard-ui .
```
### Build binary file
Prepare the assets directory
```
./prepare_assets.sh
```
Then you can embed resources by generating Go source code
```
rice embed-go
go build -o wireguard-ui
```
Or, append resources to executable as zip file
```
go build -o wireguard-ui
rice append --exec wireguard-ui
```
2020-04-25 06:13:29 +02:00
## Screenshot
![wireguard-ui](https://user-images.githubusercontent.com/6447444/80270680-76adf980-86e4-11ea-8ca1-9237f0dfa249.png)
## License
MIT. See [LICENSE](https://github.com/ngoduykhanh/wireguard-ui/blob/master/LICENSE).
2020-05-17 09:38:26 +02:00
## Support
If you like the project and want to support it, you can *buy me a coffee*
<a href="https://www.buymeacoffee.com/khanhngo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>