Skip to content

Commit ef374aa

Browse files
author
Adam Wałach
committed
initial commit
0 parents  commit ef374aa

File tree

633 files changed

+404623
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

633 files changed

+404623
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/data.db
2+
/openvpn-web-ui*
3+
/lastupdate.tmp

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Adam Wałach
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# OpenVPN-web-ui
2+
3+
## Summary
4+
OpenVPN server web administration interface.
5+
6+
Goal: create quick to deploy and easy to use solution that makes work with small OpenVPN environments a breeze.
7+
8+
![Status page](docs/images/preview_status.png?raw=true)
9+
10+
Please note this project is in alpha stage. It still needs some work to make it secure and feature complete.
11+
12+
## Motivation
13+
14+
15+
16+
## Features
17+
18+
* status page that shows server statistics and list of connected clients
19+
* easy creation of client certificates
20+
* ability to download client certificates as a zip package with client configuration inside
21+
* log preview
22+
* modification of OpenVPN configuration file through web interface
23+
24+
## Screenshots
25+
26+
[Screenshots](docs/screenshots.md)
27+
28+
## Usage
29+
30+
After startup web service is visible on port 8080. To login use the following default credentials:
31+
32+
username: admin
33+
34+
password: b3secure (this will be soon replaced with random password)
35+
36+
Please change password to your own immediately!
37+
38+
### Prod
39+
40+
Requirements:
41+
* docker and docker-compose
42+
* on firewall open ports: 1194/udp and 8080/tcp
43+
44+
Execute commands
45+
46+
curl -O https://raw.githubusercontent.com/adamwalach/openvpn-web-ui/master/docs/docker-compose.yml
47+
docker-compose up -d
48+
49+
It starts two docker containers. One with OpenVPN server and second with OpenVPNAdmin web application. Through a docker volume it creates following directory structure:
50+
51+
52+
.
53+
├── docker-compose.yml
54+
└── openvpn-data
55+
   ├── conf
56+
  │   ├── dh2048.pem
57+
   │   ├── ipp.txt
58+
   │   ├── keys
59+
   │   │   ├── 01.pem
60+
   │   │   ├── ca.crt
61+
   │   │   ├── ca.key
62+
   │   │   ├── index.txt
63+
   │   │   ├── index.txt.attr
64+
   │   │   ├── index.txt.old
65+
   │   │   ├── serial
66+
  │   │   ├── serial.old
67+
   │   │   ├── server.crt
68+
   │   │   ├── server.csr
69+
   │   │   ├── server.key
70+
   │   │   └── vars
71+
   │   ├── openvpn.log
72+
   │   └── server.conf
73+
   └── db
74+
   └── data.db
75+
76+
77+
78+
### Dev
79+
80+
Requirements:
81+
* golang environments
82+
* [beego](https://beego.me/docs/install/)
83+
84+
Execute commands:
85+
86+
go get github.com/adamwalach/openvpn-web-ui
87+
cd $GOPATH/src/github.com/adamwalach/openvpn-web-ui
88+
bee run -gendoc=true
89+
90+
## Todo
91+
92+
* add option to modify certificate properties
93+
* generate random admin password at initialization phase
94+
* add versioning
95+
96+
97+
## License
98+
99+
This project uses [MIT license](LICENSE)
100+
101+
## Remarks
102+
103+
### Vendoring
104+
https://github.com/kardianos/govendor is used for vendoring.
105+
106+
To update dependencies from GOPATH:
107+
108+
`govendor update +v`
109+
110+
### Template
111+
AdminLTE - dashboard & control panel theme. Built on top of Bootstrap 3.
112+
113+
Preview: https://almsaeedstudio.com/themes/AdminLTE/index2.html
114+

build/Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM debian:jessie
2+
WORKDIR /opt
3+
EXPOSE 8080
4+
5+
RUN apt-get update && apt-get install -y easy-rsa
6+
RUN chmod 755 /usr/share/easy-rsa/*
7+
ADD assets/start.sh /opt/start.sh
8+
ADD assets/generate_ca_and_server_certs.sh /opt/scripts/generate_ca_and_server_certs.sh
9+
ADD assets/vars.template /opt/scripts/
10+
11+
ADD openvpn-web-ui.tar.gz /opt/openvpn-gui/
12+
RUN rm -f /opt/openvpn-gui/data.db
13+
ADD assets/app.conf /opt/openvpn-gui/conf/app.conf
14+
15+
CMD /opt/start.sh

build/assets/app.conf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
appname = openvpn-web-ui
2+
httpport = 8080
3+
runmode = prod
4+
EnableGzip = true
5+
EnableAdmin = false
6+
sessionon = true
7+
CopyRequestBody = true
8+
9+
DbPath = "/opt/openvpn-gui/db/data.db"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash -e
2+
3+
CA_NAME=LocalCA
4+
SERVER_NAME=server
5+
EASY_RSA=/usr/share/easy-rsa
6+
7+
mkdir -p /etc/openvpn/keys
8+
touch /etc/openvpn/keys/index.txt
9+
echo 01 > /etc/openvpn/keys/serial
10+
cp -f /opt/scripts/vars.template /etc/openvpn/keys/vars
11+
12+
$EASY_RSA/clean-all
13+
source /etc/openvpn/keys/vars
14+
export KEY_NAME=$CA_NAME
15+
echo "Generating CA cert"
16+
#$EASY_RSA/build-ca
17+
export EASY_RSA="${EASY_RSA:-.}"
18+
19+
$EASY_RSA/pkitool --initca $*
20+
21+
export KEY_NAME=$SERVER_NAME
22+
23+
echo "Generating server cert"
24+
#$EASY_RSA/build-key-server $SERVER_NAME
25+
$EASY_RSA/pkitool --server $SERVER_NAME

build/assets/start.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
OVDIR=/etc/openvpn
5+
6+
cd /opt/
7+
8+
if [ ! -f $OVDIR/.provisioned ]; then
9+
echo "Preparing certificates"
10+
mkdir -p $OVDIR
11+
./scripts/generate_ca_and_server_certs.sh
12+
openssl dhparam -dsaparam -out $OVDIR/dh2048.pem 2048
13+
touch $OVDIR/.provisioned
14+
fi
15+
cd /opt/openvpn-gui
16+
mkdir -p db
17+
./openvpn-web-ui
18+
echo "Starting!"
19+

build/assets/vars.template

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# easy-rsa parameter settings
2+
3+
# NOTE: If you installed from an RPM,
4+
# don't edit this file in place in
5+
# /usr/share/openvpn/easy-rsa --
6+
# instead, you should copy the whole
7+
# easy-rsa directory to another location
8+
# (such as /etc/openvpn) so that your
9+
# edits will not be wiped out by a future
10+
# OpenVPN package upgrade.
11+
12+
# This variable should point to
13+
# the top level of the easy-rsa
14+
# tree.
15+
export EASY_RSA="/usr/share/easy-rsa"
16+
17+
#
18+
# This variable should point to
19+
# the requested executables
20+
#
21+
export OPENSSL="openssl"
22+
export PKCS11TOOL="pkcs11-tool"
23+
export GREP="grep"
24+
25+
26+
# This variable should point to
27+
# the openssl.cnf file included
28+
# with easy-rsa.
29+
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`
30+
31+
# Edit this variable to point to
32+
# your soon-to-be-created key
33+
# directory.
34+
#
35+
# WARNING: clean-all will do
36+
# a rm -rf on this directory
37+
# so make sure you define
38+
# it correctly!
39+
export KEY_DIR="/etc/openvpn/keys"
40+
41+
# Issue rm -rf warning
42+
echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR
43+
44+
# PKCS11 fixes
45+
export PKCS11_MODULE_PATH="dummy"
46+
export PKCS11_PIN="dummy"
47+
48+
# Increase this to 2048 if you
49+
# are paranoid. This will slow
50+
# down TLS negotiation performance
51+
# as well as the one-time DH parms
52+
# generation process.
53+
export KEY_SIZE=2048
54+
55+
# In how many days should the root CA key expire?
56+
export CA_EXPIRE=3650
57+
58+
# In how many days should certificates expire?
59+
export KEY_EXPIRE=3650
60+
61+
# These are the default values for fields
62+
# which will be placed in the certificate.
63+
# Don't leave any of these fields blank.
64+
export KEY_COUNTRY="US"
65+
export KEY_PROVINCE="NY"
66+
export KEY_CITY="New York"
67+
export KEY_ORG="dummy"
68+
export KEY_EMAIL="[email protected]"
69+
export KEY_OU="IT"
70+
71+
# X509 Subject Field
72+
export KEY_NAME="iXa-CA"
73+
74+
# PKCS11 Smart Card
75+
# export PKCS11_MODULE_PATH="/usr/lib/changeme.so"
76+
# export PKCS11_PIN=1234
77+
78+
# If you'd like to sign all keys with the same Common Name, uncomment the KEY_CN export below
79+
# You will also need to make sure your OpenVPN server config has the duplicate-cn option set
80+
# export KEY_CN="CommonName"

build/build.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
PKGFILE=openvpn-web-ui.tar.gz
6+
7+
cp -f ../$PKGFILE ./
8+
9+
docker build -t awalach/openvpn-web-ui .
10+
11+
rm -f $PKGFILE

build/pack.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
time docker run \
6+
-v "$PWD/../":/go/src/github.com/adamwalach/openvpn-web-ui \
7+
--rm \
8+
-w /usr/src/myapp \
9+
awalach/beego:1.8.1 \
10+
sh -c "cd /go/src/github.com/adamwalach/openvpn-web-ui/ && bee version && bee pack -exr='^vendor|^data.db|^build|^README.md|^docs'"

conf/app.conf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
appname = openvpn-web-ui
2+
httpport = 8080
3+
runmode = dev
4+
EnableGzip = true
5+
EnableAdmin = true
6+
sessionon = true
7+
CopyRequestBody = true
8+
9+
DbPath = "./data.db"

conf/openvpn-client-config.tpl

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
dev tun
2+
persist-tun
3+
persist-key
4+
client
5+
resolv-retry infinite
6+
remote {{ .ServerAddress }} {{ .Port }} {{ .Proto }}
7+
lport 0
8+
9+
cipher {{ .Cipher }}
10+
keysize {{ .Keysize }}
11+
auth {{ .Auth }}
12+
tls-client
13+
14+
ca {{ .Ca }}
15+
cert {{ .Cert }}
16+
key {{ .Key }}
17+
18+
comp-lzo

conf/openvpn-server-config.tpl

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
management {{ .Management }}
2+
3+
port {{ .Port }}
4+
proto {{ .Proto }}
5+
6+
dev tun
7+
8+
ca {{ .Ca }}
9+
cert {{ .Cert }}
10+
key {{ .Key }}
11+
12+
cipher {{ .Cipher }}
13+
keysize {{ .Keysize }}
14+
auth {{ .Auth }}
15+
dh {{ .Dh }}
16+
17+
server 10.8.0.0 255.255.255.0
18+
ifconfig-pool-persist {{ .IfconfigPoolPersist }}
19+
push "route 10.8.0.0 255.255.255.0"
20+
push "dhcp-option DNS 8.8.8.8"
21+
push "dhcp-option DNS 8.8.4.4"
22+
23+
keepalive {{ .Keepalive }}
24+
25+
comp-lzo
26+
max-clients {{ .MaxClients }}
27+
28+
persist-key
29+
persist-tun
30+
31+
log openvpn.log
32+
verb 3
33+
34+
mute 10

0 commit comments

Comments
 (0)