Skip to content

Commit 97232dd

Browse files
committed
Merge branch 'develop'
2 parents 4e0e1ef + ed7974d commit 97232dd

File tree

7 files changed

+350
-33
lines changed

7 files changed

+350
-33
lines changed

CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
### 1.0.2 - Official release
4+
5+
- Fixed typo in `basic_nat` example config wizard
6+
- Consistency fix in `Makefile`
7+
- Added docs for *basic_nat* example
8+
- Added docs for commands, simple setup guide
9+
- Added badges to `README.md`
10+
11+
### 1.0.1 - First version of OpenVPN container
12+
13+
Implemented:
14+
15+
- PKI handling with scripts
16+
- Hooks scripts (in separate directories)
17+
- Example config with wizard
18+
- Docker Hub hook
19+
20+
Still missing:
21+
22+
- Documentation
23+
- Dicrobadger badges

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
IMAGE_NAME=slocomptech/openvpn
77
DATA_DIR=$(shell pwd)/data
8-
CONTAINER=ovpn
8+
CONTAINER_NAME=ovpn
99

1010

1111
default: build
@@ -37,29 +37,29 @@ config:
3737
#
3838
setup:
3939
@echo "Running temporary container"
40-
docker run -it --cap-add NET_ADMIN -p 1194:1194/udp -v ${DATA_DIR}:/config --name ${CONTAINER} ${IMAGE_NAME}:latest
40+
docker run -it --cap-add NET_ADMIN -p 1194:1194/udp -v ${DATA_DIR}:/config --name ${CONTAINER_NAME} ${IMAGE_NAME}:latest
4141

4242
#
4343
# Starts container
4444
#
4545
start:
46-
docker start ${CONTAINER}
46+
docker start ${CONTAINER_NAME}
4747

4848
#
4949
# Stops container
5050
#
5151
stop:
52-
docker stop ${CONTAINER}
52+
docker stop ${CONTAINER_NAME}
5353

5454
#
5555
# Restart container
5656
#
5757
restart:
58-
docker restart ${CONTAINER}
58+
docker restart ${CONTAINER_NAME}
5959

6060
#
6161
# Open terminal inside container
6262
# Only when container is running
6363
#
6464
term:
65-
docker exec -it ${CONTAINER} bash
65+
docker exec -it ${CONTAINER_NAME} bash

README.md

+70-26
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11

2-
# [slocomptech/docker-openvpn]()
2+
# [slocomptech/docker-openvpn](https://github.com/SloCompTech/docker-openvpn)
33

4+
[![](https://images.microbadger.com/badges/version/slocomptech/openvpn.svg)](https://microbadger.com/images/slocomptech/openvpn "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/slocomptech/openvpn.svg)](https://microbadger.com/images/slocomptech/openvpn "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/commit/slocomptech/openvpn.svg)](https://microbadger.com/images/slocomptech/openvpn "Get your own commit badge on microbadger.com") ![](https://img.shields.io/docker/cloud/automated/slocomptech/openvpn.svg) ![](https://img.shields.io/docker/cloud/build/slocomptech/openvpn.svg)
45

56
Features:
67

7-
- OpenVPN is running as non-root user, soo it has limited permission.
8-
- OpenVPN is running in isolated environment (container) so you don't break it with updates, upgrades of your PC.
9-
- Easy managed (has helper scripts).
8+
- OpenVPN running as non-root user (limited permission)
9+
- Containerized (Isolated environment)
10+
- Easy managed (Helper scripts).
1011
- Easy start (Simple first-start guide).
1112
- Easly modified to your needs (see [docs](CONTRIBUTING.md)).
1213
- Easy scripting (python3 installed).
1314

1415
## Usage
1516

17+
Here are some example snippets to help you get started creating a container.
18+
1619
### docker
1720

1821
``` bash
19-
22+
# Normal start command (but you need to setup config first)
23+
docker run \
24+
--name=ovpn \
25+
--cap-add NET_ADMIN \
26+
-e PUID=1000 \
27+
-e GUID=1000 \
28+
-p 1194:1194/udp \
29+
-v </path/o/config>:/config \
30+
--restart=unless-stopped \
31+
--network host \
32+
slocomptech/openvpn:latest
2033
```
2134

2235
### docker-compose
@@ -29,6 +42,9 @@ Features:
2942

3043
|**Parameter**|**Function**|
3144
|:-----------:|:----------:|
45+
|`-e PUID=1000`|for UserID - see below for explanation|
46+
|`-e PGID=1000`|for GroupID - see below for explanation|
47+
|`-v /config`|All the config files including OpenVPNs reside here|
3248

3349
## User / Group Identifiers
3450

@@ -45,29 +61,56 @@ In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as bel
4561

4662
## Application setup
4763

48-
``` bash
49-
# Setup config directory
50-
sudo docker run -v <Config on Host>:/config --rm -it slocomptech/docker-openvpn bash
51-
$ ovpn_init
52-
# Here will ask for password for CA (needed for signing new certificates) (add nopass if you dont want to set password)
53-
# Enable basic example as config & edit /config/openvpn/server/server_*.conf & /config/openvpn/client_*.conf
54-
$ ovpn_enconf basic1
55-
# Or put your own server config in /config/openvpn/server & client template (without certs) to /config/openvpn/client
56-
# To add client (generate certificates)
57-
$ ovpn_client add <name> [nopass]
58-
# To build .ovpn file
59-
$ ovpn_client ovpn <name> > <file>
60-
# Or from outside of docker (currently not working yet)
61-
sudo docker exec -it <container name> ovpn_client add <name> nopass && ovpn_client ovpn <name> > <file>
62-
# Exit from temporary container
63-
$ exit
64-
# Run container for real
65-
sudo docker run -v <Config on Host>:/config --cap-add NET_ADMIN -p 1104:1194/udp --restart=unless-stopped slocomptech/docker-openvpn
66-
# Setup routing
64+
### Initial setup
6765

68-
```
66+
If you are new to containers please see rather [Detailed first setup guide](docs/SetupGuide.md), because it includes more detailed description.
67+
68+
1. Init configuration directory with initial config files:
69+
70+
``` bash
71+
docker run -it --rm --cap-add NET_ADMIN -v </path/to/config>:/config slocomptech/openvpn:latest bash
72+
```
73+
74+
2. At this point you will have bash shell which runs in container. Now run following commands to setup your PKI:
75+
76+
``` bash
77+
ovpn_init [nopass] # Inits PKI
78+
```
79+
80+
3. Setup OpenVPN config based on example `basic_nat` with configuration wizard:
81+
82+
``` bash
83+
ovpn_enconf basic_nat
84+
#Protocol udp, tcp, udp6, tcp6 [udp]:
85+
#VPN network [10.0.0.0]:
86+
#Port [1194]:
87+
#Public IP or domain of server: <YOUR PUBLIC IP>
88+
#DNS1 [8.8.8.8]:
89+
#DNS2 [8.8.4.4]:
90+
```
91+
4. Enable **port forwarding** on your router so OpenVPN server will be accessible from the internet.
92+
5. Add clients
93+
94+
``` bash
95+
# Generates client certificates
96+
ovpn_client add <name> [nopass]
97+
98+
# Generates client config file and prints it to screen (redirect to file)
99+
ovpn_client ovpn <name> > <config file>.ovpn
100+
101+
# OR BETTER SOLLUTION: Run outside container
102+
docker exec -it <container name> ovpn_client ovpn <name> > <config file>.ovpn
103+
```
104+
105+
5. Exit container with `exit`, then it will destroy itself.
106+
6. Start container using command specified in *Usage* section.
107+
108+
For more infromation see:
69109

70-
See more in [docs](docs).
110+
- [Detailed first setup guide](docs/SetupGuide.md)
111+
- [docs](docs) (for detailed command usage)
112+
- **configuration example directory** (for more info about example)
113+
- [Contributing](CONTRIBUTING.md) (for explanation how container works, how to write an example config ...)
71114

72115
## Contribute
73116

@@ -92,3 +135,4 @@ Wanted features (please help implement):
92135

93136
## Versions
94137

138+
See [CHANGELOG](CHANGELOG.md)

docs/README.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Documentation
2+
3+
## Table of content
4+
5+
1. Commands
6+
7+
- [Simple setup guide](SetupGuide.md)
8+
9+
## Commands
10+
11+
This section explains commands available for use.
12+
13+
### Command List
14+
15+
|**Command**|**Description**|
16+
|:---------:|:-------------:|
17+
|`ovpn_backup`|Backups your configration|
18+
|`ovpn_client`|Manages clients|
19+
|`ovpn_disconf`|Deletes active OpenVPN config|
20+
|`ovpn_enconf`|Enables OpenVPN config from examples|
21+
|`ovpn_init`|Inits PKI|
22+
23+
#### ovpn_backup
24+
25+
This command backups your configration into *.tar.gz* archive and puts it into `/config/backup` directory.
26+
27+
```
28+
Usage: ovpn_backup COMMAND
29+
30+
Commands:
31+
all # Backup whole config directory"
32+
pki # Backup PKI files"
33+
hooks # Backup hooks"
34+
openvpn # Backup openvpn live config"
35+
```
36+
37+
**Note:** Store your backups in a **SECURE** way, because they are unecrypted.
38+
39+
#### ovpn_client
40+
41+
This commands manages clients of your OpenVPN server.
42+
43+
```
44+
Usage: ovpn_client COMMAND [ARGS]
45+
46+
Commands:
47+
add [NAME [nopass]] # Creates certificates for client
48+
ovpn NAME # Builds .ovpn file
49+
revoke|ban|delete|remove NAME # Removes client
50+
```
51+
52+
**Note:** First you need to use `add` to create client certificates, before you can use `ovpn` command.
53+
54+
#### ovpn_disconf
55+
56+
This command deletes your active configuration. **Container restart** is needed for changes to take affect.
57+
58+
```
59+
Usage: ovpn_disconf
60+
```
61+
62+
**NOTE:** This command does not delete PKI.
63+
64+
#### ovpn_enconf
65+
66+
This command enables OpenVPN config based on config example. If config name isn't specified it prints out config list.
67+
68+
```
69+
Usage: ovpn_enconf CONFIG_NAME [wizard args...]
70+
71+
Configs:
72+
<example config name>
73+
```
74+
75+
**Note:** Please read example documentation to understand how to use it.
76+
**Tip:** If you modifed config in a way that others might need same configuration, consider making new example.
77+
78+
#### ovpn_init
79+
80+
This command inits your PKI in `/config/pki` folder. You need to run this command only once.
81+
82+
```
83+
Usage: ovpn_init [nopass]
84+
```
85+
86+
**Note:** Best practise is to use password for your PKI. Password is only needed for signing new certificates (when adding new clients). If you don't want your PKI certificate protected with password, add `nopass` parameter.
87+
**Note:** In this process you need to enter PKI password serveral times, because a lot of things are generated.
88+

0 commit comments

Comments
 (0)