Setup OpenVPN with OpenVPN-Monitor and docker-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "2" | |
services: | |
openvpn: | |
image: kylemanna/openvpn | |
volumes: | |
- "./data:/etc/openvpn" | |
- "/etc/localtime:/etc/localtime:ro" | |
ports: | |
- "1194:1194/udp" | |
expose: | |
- 5555 | |
cap_add: | |
- NET_ADMIN | |
openvpn_monitor: | |
image: ruimarinho/openvpn-monitor | |
environment: | |
# General | |
OPENVPNMONITOR_DEFAULT_DATETIMEFORMAT: "%d/%m/%Y %H:%M:%S" | |
OPENVPNMONITOR_DEFAULT_LOGO: https://exmaple.com/logo.png | |
OPENVPNMONITOR_DEFAULT_MAPS: "True" | |
OPENVPNMONITOR_DEFAULT_LATITUDE: "0.0" | |
OPENVPNMONITOR_DEFAULT_LONGITUDE: "0.0" | |
OPENVPNMONITOR_DEFAULT_SITE: Live | |
# Site 1 - OpenVPN1 | |
OPENVPNMONITOR_SITES_0_ALIAS: OVPN1 | |
OPENVPNMONITOR_SITES_0_HOST: openvpn | |
OPENVPNMONITOR_SITES_0_NAME: OPENVPN1 | |
OPENVPNMONITOR_SITES_0_PORT: 5555 | |
networks: | |
- default | |
- reverse | |
# ports: | |
# - "80:80" | |
networks: | |
reverse: | |
external: | |
name: web_reverse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Adapt this path for your needs | |
BASE_PATH="/mnt/data/docker/openvpn" | |
OVPN_DATA="$BASE_PATH/data" | |
echo | |
echo "### Generate clinet cert" | |
echo | |
echo "# Clientname" | |
echo "Enter the clients name:" | |
read CLIENTNAME | |
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full $CLIENTNAME nopass | |
echo | |
echo "# Retrieve config" | |
echo | |
if [ ! -d $BASE_PATH/clients ] ; then | |
mkdir $BASE_PATH/clients | |
fi | |
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient $CLIENTNAME > "$BASE_PATH/clients/$CLIENTNAME.ovpn" | |
echo | |
echo "# Wrote config to folder clients" | |
echo | |
echo "### DONE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
# Append these lines to openvpn.conf in the data folder | |
### Open Management Port | |
management 0.0.0.0 5555 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo | |
echo "### Setup OpvenVPN Server" | |
# Adapt this path for your needs | |
BASE_PATH="/mnt/data/docker/openvpn" | |
OVPN_DATA="$BASE_PATH/data" | |
SERVER_NAME="vpn.example.com" | |
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://$SERVER_NAME | |
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki | |
echo | |
echo "### Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment