openvpn
v2.7.0-alpineDependency Health
all up to dateUp-to-date dependencies
Documentation
🔐 OpenVPN Docker Container built from sources with advanced security features
This is a simple Alpine based container with OpenVPN built from sources.
Platforms
amd64
arm64
arm/v7
Features
- 🔐 Built from sources
- Dependant library
pkcs11-helperbuilt from sources - Embed
Google Authenticatorsupport
Usage
Docker
docker run -d --name openvpn \
-p 1194:1194/udp \
-v /path/to/config:/etc/openvpn \
--cap-add=NET_ADMIN \
--cap-add=NET_RAW \
--device=/dev/net/tun \
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
--sysctl net.ipv6.conf.all.forwarding=1 \
--sysctl net.ipv4.ip_forward=1 \
--sysctl net.ipv4.conf.all.forwarding=1 \
-e AUTO_INSTALL=y \
-e AUTO_START=y \
oorabona/openvpn
Docker Compose
version: '3.7'
services:
openvpn:
image: oorabona/openvpn
container_name: openvpn
restart: unless-stopped
cap_add:
- NET_ADMIN
- NET_RAW
devices:
- /dev/net/tun
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.forwarding=1
ports:
- 1194:1194/udp
volumes:
- /path/to/config:/etc/openvpn
Configuration
OpenVPN
The container is configured to use the server.conf file located in /etc/openvpn as default configuration file.
This file is generated from the script setup.sh located in /usr/local/bin and is based on the following environment variables:
- APPROVE_INSTALL
- IPV4_SUPPORT
- IPV6_SUPPORT
- PORT_CHOICE
- PROTOCOL_CHOICE
- DNS
- COMPRESSION_ENABLED
- CUSTOMIZE_ENC
- CLIENT
- PASS
- CONTINUE
- CLIENT_TO_CLIENT
- BLOCK_OUTSIDE_DNS
- OTP
- EASYRSA_CRL_DAYS
- SUBNET_IPv4
- SUBNET_IPv6
- SUBNET_MASKv4
- SUBNET_MASKv6
- ENDPOIN
For details about the meaning of each variable, please refer to the documentation.
Google Authenticator
The container is configured to use the google-authenticator library to generate the OTP code.
This library is based on the pkcs11-helper library which is built from sources.
The generated QR code is stored in the container on a per user basis under the /etc/openvpn/otp directory.
The QR code can be retrieved using the following command:
docker exec -it openvpn cat /etc/openvpn/otp/username.png
More information can be found on the wiki.
Build Arguments
The following build arguments can be passed to customize the container build:
| Argument | Default | Description |
|---|---|---|
VERSION |
latest |
OpenVPN version to build |
UPSTREAM_VERSION |
(empty) | Fallback upstream version if VERSION is not specified |
OS_VERSION |
latest |
Alpine Linux version tag |
PKCS11_HELPER_VERSION |
1.31.0 |
pkcs11-helper library version |
EASYRSA_VERSION |
3.2.2 |
EasyRSA version for certificate management |
NPROC |
1 |
Number of parallel processes for compilation |
Build options
OpenVPN is built from sources using the following options:
--enable-iproute2option to use theipcommand instead ofifconfig--enable-pkcs11option to enable thepkcs11-helperlibrary and support of PKCS#11 tokens (e.g. Yubikey)--enable-plugin-auth-pamoption to enable thepamauthentication plugin (e.g. Google Authenticator uses this)--enable-async-pushoption to allow asynchronous push of configuration options to the client (and not wait for a remote authentification request to be completed)--enable-plugin-down-rootoption to allow thedown-rootplugin to be used (e.g. to drop privileges after the connection is established). Although this option is enabled, thedown-rootplugin is not used by default.--enable-selinuxoption to enable theselinuxsupport--disable-systemdoption to disable thesystemdsupport--disable-debugoption to make the binary smaller--disable-lzoand--disable-lz4options to disable thelzoandlz4compression support (prone to side-channel attacks)--enable-comp-stuboption to disable all compression altogether (still allow limited interoperability with compression-enabled peers)
Security
SELinux
The container is configured to run with the spc_t SELinux context.
This context is configured to allow the container to access the following resources:
/etc/openvpndirectory/etc/openvpn/otpdirectory/etc/openvpn/otp/*files
Capabilities
The container is configured to run with the following capabilities:
NET_ADMINNET_RAW
Privileges
The container is configured to run as root user.
No effort has been (yet) made to run the container as a non-root user.
Security options
The container is configured to run with the following security options:
no-new-privilegesseccomp=unconfinedapparmor=unconfined
Security labels
The container is configured to run with the following security labels:
label=disablelabel=type:spc_t
Dependencies
The following third-party dependencies are pinned and monitored for updates:
| Dependency | Version | Source | Monitoring |
|---|---|---|---|
| pkcs11-helper | 1.31.0 | GitHub Release (opensc/pkcs11-helper) | Enabled |
| EasyRSA | 3.2.2 | GitHub Release (OpenVPN/easy-rsa) | Enabled |