This commit is contained in:
Emile Nijssen 2021-05-23 12:25:14 +02:00
parent 9c34761578
commit e3b7d94fa0
7 changed files with 59 additions and 4 deletions

35
README.md Normal file
View File

@ -0,0 +1,35 @@
# WireGuard Easy
## Usage
```bash
$ docker run \
--name wg-easy \
--mount type=bind,source=~/.wg-easy,target=/etc/wireguard \
--cap-add=NET_ADMIN \
--cap-add=SYS_MODULE \
--sysctl="net.ipv4.conf.all.src_valid_mark=1" \
--restart=unless-stopped \
-p 51820:51820/udp \
-p 51821:51821/tcp \
weejewel/wg-easy
```
The Web UI will be available on `http://0.0.0.0:51821`. By default, it doesn't require a password.
> Configuration files will be stored in `~/.wg-easy/` on your host.
## Options
Set options by appending them to the `docker run` command. For example, add `--env PASSWORD=foobar123` to set a password.
| Env | Default | Example | Description |
| - | - | - | - |
| `WG_HOST` | - | `vpn.myserver.com` | The public hostname of your VPN server |
| `WG_PORT` | `51820` | `51820` | The public UDP port of your VPN server |
| `PASSWORD` | - | `foobar123` | When set, requires a password when logging in to the Web UI. |
| `WG_DEFAULT_ADDRESS` | `10.8.0.x` | `10.6.0.x` | Clients IP address range |
| `WG_DEFAULT_DNS` | `1.1.1.1` | `8.8.8.8, 8.8.4.4` | DNS server clients will use |
> If you change `WG_PORT`, make sure to also change the exposed port in the `docker run` command.

View File

@ -18,4 +18,10 @@ AllowedIPs = 10.8.0.2/32
[Peer]
PublicKey = 563oiA0IuQqt8JPEXHGINT4mHYKzlLx9Ol2gcV1vKCk=
PresharedKey = Q6xGB4og5Sj6M0MsHzkD16VsniT3FCqOnGmiLLilsU8=
AllowedIPs = 10.8.0.3/32
AllowedIPs = 10.8.0.3/32
# Client: Test 3 (f1d0280c-07e7-4927-94dd-000a1723872f)
[Peer]
PublicKey =
PresharedKey =
AllowedIPs = 10.8.0.4/32

View File

@ -26,6 +26,16 @@
"createdAt": "2021-05-22T21:41:49.876Z",
"updatedAt": "2021-05-23T10:04:29.051Z",
"enabled": true
},
"f1d0280c-07e7-4927-94dd-000a1723872f": {
"name": "Test 3",
"address": "10.8.0.4",
"privateKey": "",
"publicKey": "",
"preSharedKey": "",
"createdAt": "2021-05-23T10:21:24.607Z",
"updatedAt": "2021-05-23T10:21:24.607Z",
"enabled": true
}
}
}

View File

@ -3,7 +3,7 @@
module.exports.PORT = process.env.PORT || 51821;
module.exports.PASSWORD = process.env.PASSWORD;
module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/';
module.exports.WG_HOST = process.env.WG_HOST || '127.0.0.1';
module.exports.WG_HOST = process.env.WG_HOST;
module.exports.WG_PORT = process.env.WG_PORT || 51820;
module.exports.WG_DEFAULT_ADDRESS = process.env.WG_DEFAULT_ADDRESS || '10.8.0.x';
module.exports.WG_DEFAULT_DNS = process.env.WG_DEFAULT_DNS || '1.1.1.1';

View File

@ -22,6 +22,10 @@ module.exports = class WireGuard {
async getConfig() {
if (!this.__configPromise) {
this.__configPromise = Promise.resolve().then(async () => {
if (!WG_HOST) {
throw new Error('WG_HOST Environment Variable Not Set!');
}
let config;
try {
config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8');

View File

@ -4,7 +4,7 @@
"description": "",
"main": "server.js",
"scripts": {
"serve": "DEBUG=Server WG_PATH=../config/ nodemon server.js",
"serve": "DEBUG=Server WG_HOST=0.0.0.0 WG_PATH=../config/ nodemon server.js",
"serve-with-password": "PASSWORD=wg npm run serve"
},
"author": "Emile Nijssen",

View File

@ -2,4 +2,4 @@
const Server = require('../lib/Server');
module.exports = new Server();
module.exports = new Server();