Giter Site home page Giter Site logo

d3vilh / openvpn-ui Goto Github PK

View Code? Open in Web Editor NEW
168.0 5.0 36.0 38.84 MB

Web User Interface for OpenVPN

License: MIT License

Dockerfile 0.02% Shell 0.80% Smarty 0.06% Go 1.94% CSS 43.35% JavaScript 50.78% HTML 3.05%
openvpn openvpn-admin openvpn-configuration openvpn-server openvpn-ui web-interface

openvpn-ui's Introduction

OpenVPN UI

OpenVPN server web administration interface.

Quick to deploy and easy to use, makes work with small OpenVPN environments a breeze.

Openvpn-ui home screen

latest version Docker Image Version (tag latest semver) Docker Image Size (tag)

latest version Docker Image Version (tag latest semver)

Features

  • Status page that shows server statistics and list of connected clients
  • Supports OpenVPN tunnel(dev tun) or bridge(dev tap) server configurations
  • Easy to generate, download, renew, revoke, delete and view client certificates
  • Client can have secret passphrase and static IP assigned during client certificate generation
  • Two factor authentication (2FA/MFA) support
  • Change predefined EasyRSA vars including certificates and CRL expiration time
  • Maintain EasyRSA PKI infrastructure (init, build-ca, gen-dh, build-crl, gen-ta, revoke)
  • Change OpenVPN Server configuration via web interface
  • Easy to preview OpenVPN Server logs
  • Restart OpenVPN Server and OpenVPN UI from web interface
  • OpenVPN-UI users management. Administrators has full access, regular users to Certificates management, logs and status page only.
  • OpenVPN-UI Admin user and password can be passed via environment variables to container
  • Updated infrustracture:
    • Alpine Linux as fastest and secure base image
    • GoLang 1.21
    • Beego 2.1 with all vulnerabilities fixed
    • Easy-rsa 3.X
    • Openssl 3.X
    • OpenVPN 2.5.8 Server is fully compatible
  • Support any architecture, ready images for AMD64 and ARM available on Docker Hub.

Part of following projects:

  • Openvpn-aws OpenVPN and OpenVPN-UI for any Cloud, VM or x86 bare metal server.
  • Raspberry-gateway simple yet powerful home gateway environment with Pi-Hole +Unbound, VPN, Torrent client and Internet monitoring, all managed by Portainer.

Installation

For the best experience, it is recommended to deploy it within a Docker environment consisting of two distinct containers:

  • The d3vilh/openvpn-server Back-End container (openvpn) for running OpenVPN server.
  • OpenVPN UI Front-End container (openvpn-ui) for efficient management of the OpenVPN server environment.

However it works fine as standalone application with standalove OpenVPN server as well.

Intel x86 and AMD64 platforms

You can run both containers from the official openvpn-server repository, docker-compose-openvpnui.yml. It includes all the files in its main directory.

For automated installation on baremetal x86-64 servers, Cloud or VM installation, please use openvpn-aws project. It, as well, includes all the necessary scripts for easy installation of OpenVPN-UI and OpenVPN server on any x86-64 platform.

Raspberry-pi and other ARM platforms

For Raspberry-Pi and other ARM devices, consider Raspberry-Gateway project. It has all the necessary scripts for easy installation and lot of additional features.

You can run both containers from the openvpn-server repository as well (use docker-compose-openvpnui.yml). It includes all the files in its main directory, as well.

Manual installation

With Docker-compose

Running this image with docker-compose.yml file

    openvpn-ui:
       container_name: openvpn-ui
       image: d3vilh/openvpn-ui:latest
       environment:
           - OPENVPN_ADMIN_USERNAME={{ ovpnui_user }}
           - OPENVPN_ADMIN_PASSWORD={{ ovpnui_password }}
       privileged: true
       ports:
           - "8080:8080/tcp"
       volumes:
           - ./:/etc/openvpn
           - ./db:/opt/openvpn-ui/db
           - ./pki:/usr/share/easy-rsa/pki
           - /var/run/docker.sock:/var/run/docker.sock:ro
       restart: always

You can couple OpenVPN-UI with recommended d3vilh/openvpn-server image and here is updated docker-compose.yml for it:

---
version: "3.5"

services:
    openvpn:
       container_name: openvpn
       image: d3vilh/openvpn-server:latest
       privileged: true
       ports: 
          - "1194:1194/udp"
       environment:
           TRUST_SUB: 10.0.70.0/24
           GUEST_SUB: 10.0.71.0/24
           HOME_SUB: 192.168.88.0/24
       volumes:
           - ./pki:/etc/openvpn/pki
           - ./clients:/etc/openvpn/clients
           - ./config:/etc/openvpn/config
           - ./staticclients:/etc/openvpn/staticclients
           - ./log:/var/log/openvpn
           - ./fw-rules.sh:/opt/app/fw-rules.sh
           - ./server.conf:/etc/openvpn/server.conf
       cap_add:
           - NET_ADMIN
       restart: always

    openvpn-ui:
       container_name: openvpn-ui
       image: d3vilh/openvpn-ui:latest
       environment:
           - OPENVPN_ADMIN_USERNAME=admin
           - OPENVPN_ADMIN_PASSWORD=gagaZush
       privileged: true
       ports:
           - "8080:8080/tcp"
       volumes:
           - ./:/etc/openvpn
           - ./db:/opt/openvpn-ui/db
           - ./pki:/usr/share/easy-rsa/pki
           - /var/run/docker.sock:/var/run/docker.sock:ro
       restart: always

Where:

  • TRUST_SUB is Trusted subnet, from which OpenVPN server will assign IPs to trusted clients (default subnet for all clients)
  • GUEST_SUB is Gusets subnet for clients with internet access only
  • HOME_SUB is subnet where the VPN server is located, thru which you get internet access to the clients with MASQUERADE
  • fw-rules.sh is bash file with additional firewall rules you would like to apply during container start

docker_entrypoint.sh will apply following Firewall rules:

IPT MASQ Chains:
MASQUERADE  all  --  ip-10-0-70-0.ec2.internal/24  anywhere
MASQUERADE  all  --  ip-10-0-71-0.ec2.internal/24  anywhere
IPT FWD Chains:
       0        0 DROP       1    --  *      *       10.0.71.0/24         0.0.0.0/0            icmptype 8
       0        0 DROP       1    --  *      *       10.0.71.0/24         0.0.0.0/0            icmptype 0
       0        0 DROP       0    --  *      *       10.0.71.0/24         192.168.88.0/24

Here is possible content of fw-rules.sh file to apply additional rules:

~/openvpn-server $ cat fw-rules.sh
iptables -A FORWARD -s 10.0.70.88 -d 10.0.70.77 -j DROP
iptables -A FORWARD -d 10.0.70.77 -s 10.0.70.88 -j DROP
With Dockerfile

Run this image using the Dockerfile

Run the OpenVPN-UI image

docker run \
-v /home/pi/openvpn:/etc/openvpn \
-v /home/pi/openvpn/db:/opt/openvpn-ui/db \
-v /home/pi/openvpn/pki:/usr/share/easy-rsa/pki \
-v /home/pi/openvpn/log:/var/log/openvpn \
-v /var/run/docker.sock:/var/run/docker.sock \
-e OPENVPN_ADMIN_USERNAME='admin' \
-e OPENVPN_ADMIN_PASSWORD='gagaZush' \
-p 8080:8080/tcp \
--privileged d3vilh/openvpn-ui:latest

Run the OpenVPN Server image:

cd ~/openvpn-server/ && 
docker run  --interactive --tty --rm \
  --name=openvpn-server \
  --cap-add=NET_ADMIN \
  -p 1194:1194/udp \
  -e TRUST_SUB=10.0.70.0/24 \
  -e GUEST_SUB=10.0.71.0/24 \
  -e HOME_SUB=192.168.88.0/24 \
  -v ./pki:/etc/openvpn/pki \
  -v ./clients:/etc/openvpn/clients \
  -v ./config:/etc/openvpn/config \
  -v ./staticclients:/etc/openvpn/staticclients \
  -v ./log:/var/log/openvpn \
  -v ./fw-rules.sh:/opt/app/fw-rules.sh \
  -v ./server.conf:/etc/openvpn/server.conf \
  --privileged d3vilh/openvpn-server:latest
Building own image

Building own image

Prerequisites

As prerequisite, you need to have Docker and GoLang to be installed and running:

sudo apt-get install docker.io -y
sudo systemctl restart docker

To install Golang go to https://go.dev/dl and copy download URL for Go1.20.X version of your arch and follow the instructions below.

Example for ARM64:

wget https://golang.org/dl/go1.20.linux-arm64.tar.gz
sudo tar -C /usr/local -xzf go1.20.linux-arm64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
source /etc/profile
go version 
Building the image

To build the OpenVPN-UI image:

cd build; ./build_openvpn-ui.sh

The new image will have openvpn-ui name.

Standalone installation

Standalone installation without docker and docker-compose

If you have your OpenVPN server up and running on the same host, you can install OpenVPN-UI as standalone application. For this you need to have GoLang installed on your host to build all the necessary binaries on the server itself.

To make installation easier, version 0.9.5 now includes a standalone-install.sh script. This script helps you step by step, starting with downloading and installing GoLang, and ending with building the binaries.

At the moment script supports Debian based systems only.

Here is installation process example:

superdude@bookworm64:~/build/openvpn-ui/build$ ./standalone-install.sh
This script will install OpenVPN-UI and all the dependencies on your local environment. No containers will be used.
Do you want to continue? (y/n)y
Golang version 1.21 is not installed.
Would you like to install it? (y/n) y
--2024-02-20 16:37:47--  https://golang.org/dl/go1.21.5.linux-amd64.tar.gz
go1.21.5.linux-amd64.tar.gz      100%[========================================================>]  63.53M  3.01MB/s    in 20s
2024-02-20 16:38:08 (3.23 MB/s) - 'go1.21.5.linux-amd64.tar.gz' saved [66618285/66618285]
Would you like to run apt-get update? (y/n) y
Updating current environment with apt-get update
[sudo] password for superdude:
No VM guests are running outdated hypervisor (qemu) binaries on this host.
Would you like to download all necessary Go modules? (y/n) y
Downloading all Go modules (go mod download)
Would you like to install Beego v2? (y/n) y
Installing BeeGo v2
go: downloading github.com/beego/bee/v2 v2.0.2-0.20230830024958-01d397161933
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.4
Would you like to build OpenVPN-UI and install qrencode? (y/n) y
Installing OpenVPN-UI and qrencode
Cloning qrencode into build directory
Cloning into 'qrencode'...
remote: Enumerating objects: 35, done.
Resolving deltas: 100% (8/8), done.
Building and packing OpenVPN-UI
2024/02/20 17:15:07 INFO     ▶ 0001 Getting bee latest version...
2024/02/20 17:15:08 INFO     ▶ 0002 Your bee are up to date
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v2.1.0
2024/02/20 17:20:55 SUCCESS  ▶ 0004 Build Successful!
2024/02/20 17:21:02 SUCCESS  ▶ 0009 Application packed!
Building qrencode
Moving qrencode to GOPATH
All done.
superdude@bookworm64:~/build/openvpn-ui/build$ 

After build and installation is complete:

  1. Put archive openvpn-ui.tar.gz with binaries to the desired directory where you would like to run OpenVPN-UI from.
  2. Uncompress it with tar -xzf openvpn-ui.tar.gz.
  3. Double check openvpn-ui binary has +x permissions for your user.
  4. Create db directory in the same directory where openvpn-ui binary is located.
  5. Update OpenVpnPath and EasyRsaPath with real location of your OpenVPN server config (/etc/openvpn) and EasyRSA (/usr/share/easy-rsa) in main application config file - ./conf/app.conf file.
  6. Set EnableAdmin = false and RunMode = prod in the same file, if you don't need to run BeeGo in development mode and don't need BeeGo admin console to run (in most cases you don't need it).
  7. On the first run set OPENVPN_ADMIN_USERNAME and OPENVPN_ADMIN_PASSWORD environment variables to create admin user with secret password:
export OPENVPN_ADMIN_USERNAME=admin
export OPENVPN_ADMIN_PASSWORD=$3kR3tPa$Sw0rd
  1. doublecheck enviroment variables are set properly:
echo $OPENVPN_ADMIN_USERNAME
echo $OPENVPN_ADMIN_PASSWORD

This should return your username and password you will use for the first login into UI. It is mandatory to set this vars on the first application start only. So OpenVPN-UI will create your Admin user with your own credentials.

  1. Run ./openvpn-ui binary and login with your new credentials.

  2. Go to Configuration > OpenVPN Server and update all the fields with your current server.conf options.

  3. For security reasons you have to unset vars after successful login, so it will be removed from the local server environment:

unset OPENVPN_ADMIN_USERNAME
unset OPENVPN_ADMIN_PASSWORD

Upgrade to new Version

During the installtion or upgrade process OpenVPN-UI by itself does not do any changes to your OpenVPN server configuration or PKI infrastructure. However it is recommended to perform backup of your PKI infrastructure, server.conf, client.conf and data.db before following with upgrade steps.

Backup

Backup

To backup your PKI infrastructure, server, client configuration files and OpenVPN-UI DB you can use backup.sh script which is in build/assets directory (since the release 0.6), it is also part of openvpn-aws and Raspberry-Gateway projects (right in openvpn-server directory).

Copy the script in your home directory(any directory in fact):

cp -p build/assets/backup.sh ~/

Then run the script:

sudo ./backup.sh -b ~/openvpn-server backup/openvpn-server-030923-1

this will create backup of all necessary files, from ~/openvpn-server to ~/backup/openvpn-server-030923-1.

You can confirm all files are backed up and go to the "Upgrade" step.

Upgrade

Upgrade

To upgrade OpenVPN-UI to the latest version, you have to save old container image, remove old container and deploy new container with upgraded image.

Preparation
  1. Check which OpenVPN-UI version image is currently used:
docker inspect --format='{{json .Config.Labels}}' d3vilh/openvpn-ui:latest
{"maintainer":"Mr.Philipp <[email protected]>","version":"0.5"}

Note: Old container versions (below ver 0.5) does not have "version" tag.

  1. Tag current container image with backup tag:
docker tag d3vilh/openvpn-ui:latest local/openvpn-ui:backup
  1. Make sure your docker-compose.yml file is up to date with desired new version of image. Our assumption that desired is the latest version:
admin@aws3:~/openvpn $ cat docker-compose.yml | grep image
       image: d3vilh/openvpn-ui:latest
admin@aws3:~/openvpn $

During the next container start, docker will use image tag from this file to deploy new container.

Upgrade Steps
  1. Pull new image to your host. Old image will be replaced:
docker pull d3vilh/openvpn-ui:latest
  1. Confirm new image is pulled with desired version:
docker inspect --format='{{json .Config.Labels}}' d3vilh/openvpn-ui:latest
{"maintainer":"Mr.Philipp <[email protected]>","version":"0.9.4"}
  1. Stop and remove old container:
docker rm openvpn-ui --force
  1. Deploy new container with updated image:
cd ~/openvpn-server
docker-compose up -d
  1. Verify both containers are up and running:
admin@aws3:~/openvpn $ docker logs openvpn-ui
...
2023/09/03 12:38:50.650 [I] [server.go:280]  http server Running on http://:8080
admin@aws3:~/openvpn $

admin@aws3:~/openvpn $ docker logs openvpn
...
Start openvpn process...
admin@aws3:~/openvpn $
Verification process

Now when new OpenVPN-UI version is deployed, the DB schema were updated to the latest version automatically during the container start.

  • All tables were updated with new fields, existed fields in those tables were not touched to be sure you won't loose any data.
  • New tables were created with default values.

Now you need to go to Configuration > OpenVPN Server in OpenVPN UI webpage and review and update all options fields very carefully.

Here is example of Server configuration page with new fields after the upgrade from version 0.3 to 0.9:

Openvpn-ui upgrade

You have to update empty fields with options from your current server.conf and only then press Save Config button.

All fields to review are marked with ! sign:

Openvpn-ui upgrade

Here is how it should looks like:

Openvpn-ui upgrade

Important Note!: In version 0.6 format of some fields has been changed! Please pay attention that before saving config you have to update all the fields with new format, otherwise OpenVPN Server will not start.

New server.conf file will be applied immedeately, after you press Save Config button.

Next, you have to update OpenVPN UI, OpenVPN Client and EasyRSA vars pages the same way.

And you are done with the upgrade process.

DB Schema changes
DB Schema changes 0.3 to 0.9 versions

You have nothing to do with the DB schema, just for your information.

Version Table New Field New OpenVPN UI gui location
0.3 o_v_config o_v_config_log_version Configuration > OpenVPN Server
0.3 o_v_config o_v_config_status_log Configuration > OpenVPN Server
0.3 settings server_address moved to Configuration > OpenVPN Client
0.3 settings open_vpn_server_port moved to Configuration > OpenVPN Client
0.4 o_v_client_config new table Configuration > OpenVPN Client
0.4 easy_r_s_a_config new table Configuration > EasyRSA vars
0.4 settings easy_r_s_a_path Configuration > OpenVPN-UI
0.5 no schema changes no schema changes no schema changes
0.6 o_v_config o_v_config_topology Configuration > OpenVPN Server
0.6 o_v_config o_v_config_user Configuration > OpenVPN Server
0.6 o_v_config o_v_config_group Configuration > OpenVPN Server
0.6 o_v_config o_v_config_client_config_dir Configuration > OpenVPN Server
0.6 o_v_config crl Configuration > OpenVPN Server
0.6 o_v_config t_l_s_control_channel Configuration > OpenVPN Server
0.6 o_v_config t_l_s_min_version Configuration > OpenVPN Server
0.6 o_v_config t_l_s_remote_cert Configuration > OpenVPN Server
0.6 o_v_config o_v_config_ncp_ciphers Configuration > OpenVPN Server
0.6 o_v_config o_v_config_logfile Configuration > OpenVPN Server
0.6 o_v_config o_v_config_log_verbose Configuration > OpenVPN Server
0.6 o_v_config o_v_config_status_log Configuration > OpenVPN Server
0.6 o_v_config o_v_config_status_log_version Configuration > OpenVPN Server
0.6 o_v_config custom_opt_one Configuration > OpenVPN Server
0.6 o_v_config custom_opt_two Configuration > OpenVPN Server
0.6 o_v_config custom_opt_three Configuration > OpenVPN Server
0.7 no schema changes no schema changes no schema changes
0.8 no schema changes no schema changes no schema changes
0.9 no schema changes no schema changes Donate here https://u24.gov.ua
0.9.2 user is_admin Your username > Profile
0.9.3 o_v_config func_mode Configuration > OpenVPN Server
0.9.3 o_v_config script_security Configuration > OpenVPN Server
0.9.3 o_v_config user_pass_verify Configuration > OpenVPN Server
0.9.3 o_v_client_config func_mode Configuration > OpenVPN Client
0.9.3 o_v_client_config t_f_a_issuer Configuration > OpenVPN Client
0.9.3 o_v_client_config custom_conf_one Configuration > OpenVPN Client
0.9.3 o_v_client_config custom_conf_two Configuration > OpenVPN Client
0.9.3 o_v_client_config custom_conf_three Configuration > OpenVPN Client
0.9.4 no schema changes no schema changes no schema changes
0.9.5 no schema changes no schema changes no schema changes
Fallback

Fallback

If for some reason you would like to fallback to the previous version, you need to stop container, restore image, then restore all the files from backup you did before and finally run container with previous image.

Container and image fallback
  1. Stop and remove updated openvpn-ui container:
docker rm openvpn-ui --force
  1. Remove updated openvpn-ui image:
docker image rm d3vilh/openvpn-ui:latest
  1. Restore old openvpn-ui image:
docker tag local/openvpn-ui:backup d3vilh/openvpn-ui:latest
  1. Confirm you have old image version:
docker inspect --format='{{json .Config.Labels}}' d3vilh/openvpn-ui:latest
{"maintainer":"Mr.Philipp <[email protected]>","version":"0.5"}
Restore OpenVPN Server enviroment
  1. Run restore script:
sudo ./backup.sh -r ~/openvpn-server backup/openvpn-server-030923-1

This will restore all the enviroment files from backup directory to ~/openvpn-server directory.

Note v.0.3: There was bug in version 0.3 where data.db file were not shared over the volume, so you have to restore it manually: docker cp backup/data.0.3.db openvpn-ui:/opt/openvpn-ui/data.db

Restore container
  1. Run docker-compose up to deploy new container with old image:
cd ~/openvpn-server
docker-compose up -d
  1. Verify both containers are up and running:
admin@aws3:~/openvpn $ docker logs openvpn-ui
...
2023/09/03 12:38:50.650 [I] [server.go:280]  http server Running on http://:8080
admin@aws3:~/openvpn $

admin@aws3:~/openvpn $ docker logs openvpn
...
Start openvpn process...
admin@aws3:~/openvpn $

Thats it you are back to the previous version.

Configuration

OpenVPN UI can be accessed on own port (*e.g. http://localhost:8080), the default user and password is admin/gagaZush preconfigured in config.yml if you are using Raspberry-Gateway or Openvpn-aws projects. For standalone installation, you can pass your own credentials via environment variables to container (refer to Manual installation).

Container volume

The container volume can be initialized by using the d3vilh/openvpn-server image with included scripts to automatically generate everything you need on the first run:

  • Diffie-Hellman parameters
  • an EasyRSA CA key and certificate
  • a new private key
  • a self-certificate matching the private key for the OpenVPN server
  • a TLS auth key from HMAC security

However you can generate all the above components on OpenVPN UI Configuration > Maintenance page.

EasyRSA vars

You can update all EasyRSA parameters with OpenVPN UI on Configuration > EasyRSA vars page. You also can set custom EasyRSA vars for every new Client Certificate during its creation.

If you are running OpenVPN-UI as manuall installation, please be sure easy-rsa.vars is set properly and placed in .config container volume as easy-rsa.vars.

In this case your custom EasyRSA options will be applied on the first OpenVPN Server start post PKI init step.

Default EasyRSA configuration can be set in ~/openvpn-server/config/easy-rsa.vars file:

set_var EASYRSA_DN           "org"
set_var EASYRSA_REQ_COUNTRY  "UA"
set_var EASYRSA_REQ_PROVINCE "KY"
set_var EASYRSA_REQ_CITY     "Kyiv"
set_var EASYRSA_REQ_ORG      "SweetHome"
set_var EASYRSA_REQ_EMAIL    "[email protected]"
set_var EASYRSA_REQ_OU       "MyOrganizationalUnit"
set_var EASYRSA_REQ_CN       "server"
set_var EASYRSA_KEY_SIZE     2048
set_var EASYRSA_CA_EXPIRE    3650
set_var EASYRSA_CERT_EXPIRE  825
set_var EASYRSA_CERT_RENEW   30
set_var EASYRSA_CRL_DAYS     180

In the process of installation these vars will be copied to container volume /etc/openvpn/pki/vars and used during all EasyRSA operations.

Network configuration

This setup use tun mode by default, because it works on the widest range of devices. tap mode, for instance, does not work on Android, except if the device is rooted.

The default topology is subnet, because it works on the widest range of OS. p2p, for instance, does not work on Windows.

The server config by default specifies push redirect-gateway def1 bypass-dhcp, meaning that after establishing the VPN connection, all traffic will go through the VPN. This might cause problems if you use local DNS recursors which are not directly reachable, since you will try to reach them through the VPN and they might not answer to you. If that happens, use public DNS resolvers like those of OpenDNS (208.67.222.222 and 208.67.220.220) or Google (8.8.4.4 and 8.8.8.8).

If you wish to use your local DNS server (Pi-Hile?), you have to modify a dns-configuration with your local DNS IP address.

This also can be done easy via "Configuration" > "OpenVPN Server" > "Push DHCP" options on OpenVPN UI webpage.

OpenVPN client subnets. Guest and Home users

By default d3vilh/openvpn-server OpenVPN server uses option server 10.0.70.0/24 as "Trusted" subnet to grab dynamic IPs for all your Clients which, by default will have full access to your "Private/Home" subnet, as well as Internet over VPN. However you can be desired to share internet over VPN with specific, Guest Clients and restrict access to your "Private/Home" subnet. For this scenario d3vilh/openvpn-server server.conf configuration file has special route 10.0.71.0/24 option, aka "Guest users" subnet.

OpenVPN Subnets

To assign desired subnet policy to the specific client, you have to define static IP address for the client during its profile/Certificate creation. To do that, just enter "Static IP (optional)" field in "Certificates" page and press "Create" button.

Keep in mind, by default, all the clients have full access, so you don't need to specifically configure static IP for your own devices, your home devices always will land to "Trusted" subnet by default.

Firewall rules

By default docker_entrypoint.sh of d3vilh/openvpn-server OpenVPN Server container will apply following Firewall rules:

IPT MASQ Chains:
MASQUERADE  all  --  ip-10-0-70-0.ec2.internal/24  anywhere
MASQUERADE  all  --  ip-10-0-71-0.ec2.internal/24  anywhere
IPT FWD Chains:
       0        0 DROP       1    --  *      *       10.0.71.0/24         0.0.0.0/0            icmptype 8
       0        0 DROP       1    --  *      *       10.0.71.0/24         0.0.0.0/0            icmptype 0
       0        0 DROP       0    --  *      *       10.0.71.0/24         192.168.88.0/24

You can apply optional Firewall rules in ~/openvpn-server/fw-rules.sh file, which will be executed on the container start.

Here is example of blocking all the traffic between 2 "Trusted" subnet clients:

~/openvpn-server $ cat fw-rules.sh
iptables -A FORWARD -s 10.0.70.88 -d 10.0.70.77 -j DROP
iptables -A FORWARD -d 10.0.70.77 -s 10.0.70.88 -j DROP

Check detailed subnets description on here.

OpenVPN Pstree structure

All the Server and Client configuration located in Docker volume and can be easely tuned. Here are tree of volume content:

|-- server.conf   //OpenVPN server configuration file
|-- clients
|   |-- your_client1.ovpn
|-- config
|   |-- client.conf
|   |-- easy-rsa.vars //EasyRSA vars draft, see below real vars file.
|-- db
|   |-- data.db       //OpenVPN UI DB
|-- log
|   |-- openvpn.log
|-- pki
|   |-- ca.crt
|   |-- vars          // EasyRSA real vars, used by all applications
|   |-- certs_by_serial
|   |   |-- your_client1_serial.pem
|   |-- crl.pem
|   |-- dh.pem
|   |-- index.txt
|   |-- ipp.txt
|   |-- issued
|   |   |-- server.crt
|   |   |-- your_client1.crt
|   |-- openssl-easyrsa.cnf
|   |-- private
|   |   |-- ca.key
|   |   |-- your_client1.key
|   |   |-- server.key
|   |-- renewed
|   |   |-- certs_by_serial
|   |   |-- private_by_serial
|   |   |-- reqs_by_serial
|   |-- reqs
|   |   |-- server.req
|   |   |-- your_client1.req
|   |-- revoked
|   |   |-- certs_by_serial
|   |   |-- private_by_serial
|   |   |-- reqs_by_serial
|   |-- safessl-easyrsa.cnf
|   |-- serial
|   |-- ta.key
|-- staticclients    //Directory where stored all the satic clients configuration

Generating .OVPN client profiles

How to generate .OVPN client profile You can update external client IP and port address anytime under `"Configuration > OpenVPN Client"` menue.

For this go to "Configuration > OpenVPN Client":

Configuration > Settings

And then update "Connection Address" and "Connection Port" fields with your external Internet IP and Port.

To generate new Client Certificate go to "Certificates", then press "Create Certificate" button, enter new VPN client name, complete all the rest fields and press "Create" to generate new Client certificate:

Server Address Create Certificate

To download .OVPN client configuration file, press on the Client Name you just created:

download OVPN

Install Official OpenVPN client to your client device.

Deliver .OVPN profile to the client device and import it as a FILE, then connect with new profile to enjoy your free VPN:

PalmTX Import PalmTX Connected

Renew Certificates for client profiles

How to renew old client profile To renew certificate, go to `"Certificates"` and press `"Renew"` button for the client you would like to renew certificate for: Renew OpenVPN Certificate

Right after this step new Certificate will be genrated and it will appear as new client profile with the same Client name. At this point both client profiles will have updated Certificate when you try to download it.

Once you will deliver new client profile with renewed Certificate to you client, press "Revoke" button for old profile to revoke old Certificate, old client profile will be deleted from the list.

If, for some reason you still would like to keep old certificate you have to "Revoke" new profile, old certificate will be rolled back and new profile will be deleted from the list.

Renewal process will not affect active VPN connections, old client will be disconnected only after you revoke old certificate or certificate term of use will expire.

Revoking .OVPN profiles

How to revoke client certificate

If you would like to prevent client to use yor VPN connection, you have to revoke client certificate and restart the OpenVPN daemon. You can do it via OpenVPN UI "Certificates" menue, by pressing `"Revoke"`` amber button:

Revoke Certificate

Certificate revoke won't kill active VPN connections, you'll have to restart the service if you want the user to immediately disconnect. It can be done from the same "Certificates" page, by pressing Restart red button:

OpenVPN Restart

You can do the same from the "Maintenance" page.

After Revoking and Restarting the service, the client will be disconnected and will not be able to connect again with the same certificate. To delete the certificate from the server, you have to press "Remove" button.

Two Factor Authentication (2FA)

Starting from vestion 0.9.3 OpenVPN-UI has Two Factor Authentication (2FA) feature. OpenVPN-UI uses oath-toolkit for two factor authentication. Means you don't need any ThirdParty 2FA provider. When generating 2FA-enabled certificates OpenVPN-UI will provide QR code with 2FA secret, which you can scan with your 2FA app (Google Authenticator iOS, Android, Microsoft Authenticator iOS, Android, etc) to get 2FA token for connection with this certificate.

2FA Certificates Renewal, Revoke and Delete process is the same as for regular certificates.

To enable 2FA you have to:

  • Go to "Configuration > OpenVPN Client" page and enable "Two Factor Authentication" option to switch Certificates interface to 2FA mode, so you can generate certificates with 2FA enabled and access 2FA QR code for already generated certificates.

    Note: You can generate 2FA-ready certificates at this stage, then deliver 2FA Certificates to all your client devices and enable 2FA Server support later, when you'll be ready to use it. Before that Server will still accept non 2FA-ready certificates only.

  • Go to "Configuration > OpenVPN Server" page and enable "Two Factor Authentication" option for OpenVPN Server backend. Once 2FA is enabled for Server, OpenVPN-Server will allow 2FA connections only (non 2FA-ready certificates won't connect).

2FA .OVPN profiles creation

How to generate 2FA Certificate

Procedure for 2FA generation is the same as for regular certificate, but you have to use the uniq 2FA Name in the email-kind format:

2FA Certificate create

Note: For Multifactor Authentication (MFA), you can add one more password by completing Passphrase option.

Both Passphrase and Client Static IP are optional parameters.

When you complete all the fields, click on Create and your new 2FA Certificate will be ready.

Once this done, you can click on the new certificate in the Certificates page to see all the details including QR code for 2FA token:

2FA Certificate details

You can copy or email this information directly to happy 2FA certificate owner.

2FA certificates usage

How to add 2FA profile to client

To use 2FA certificate you have to install 2FA app on your device (Google Authenticator iOS, Android, Microsoft Authenticator iOS, Android, etc) and scan QR code from the Certificates details page.

After scanning QR-code, new Authenticator profile will be created in your 2FA app with the same name as your 2FA Certificate name:

2FA Authenticator

Then you have to download and deliver .OVPN profile to OpenVPN Connect app and open it as a file. Following window appear:

2FA OpenVPN Connect profile add

Click Add to add new profile to OpenVPN Connect. Then you will be asked to enter your Username. As username use 2FA Name which you used during Certificate/profile generation (as precisely as you can. 2FA Name is part of authentication process):

2FA OpenVPN Connect profile username

When you'll be prompted to Enter the password, you have to enter your 2FA token from your 2FA app:

2FA OpenVPN Connect profile 2FA password

Connection will be suceeded if you entered 2FA Name and 2FA token correctly.

For MFA authentication you can use optional Passphrase when generating new Client certificate, to protect your 2FA token with additional password. In this case you have to enter your Passphrase as a Private Key Password and 2FA token as Password:

2FA OpenVPN Connect profile 2FA and Certificate passwords

User Management

Starting from v.0.9.2 OpenVPN UI has user management feature.

You can create and delete users with different privileges - Administrators or regular users:

  • Administrators has full access
  • Regular users has access to Home page, Certificates and Logs pages only. This users can create, renew, revoke and delete all the certificates.
How to manage OpenVPN-UI Users

This functionality available via "Users Profiles" page:

Username > Profile

Then, if your user have enough privilegies you can Create new profile or manage profiles of other users:

New OpenVPN UI Profile creation OpenVPN UI Profiles management

Screenshots:

OpenVPN-UI Login screen

OpenVPN-UI Home screen

OpenVPN-UI Certificates screen

OpenVPN-UI Create Certificate screen

OpenVPN-UI Expire Certificate details

OpenVPN-UI OK Certificate details

OpenVPN-UI EasyRSA vars screen

OpenVPN-UI EasyRSA vars config view screen

OpenVPN-UI Maintenance screen

OpenVPN-UI Server Configuration screen

OpenVPN-UI Server Configuration edit screen

OpenVPN-UI Client Configuration screen

OpenVPN-UI Configuration screen

OpenVPN-UI User Profile

New OpenVPN UI Profile creation

OpenVPN UI Profiles management

OpenVPN-UI Logs screen

Дякую and Kudos to the initiator of this project

Kudos to @adamwalach for development of the original OpenVPN-WEB-UI project which was used as solid foundation for OpenVPN UI.

Buy Me A Coffee

openvpn-ui's People

Contributors

d3vilh avatar vfdev-5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

openvpn-ui's Issues

How to increase certificate expiration?

Hello,
as far as I can see, the default expiration date of the certificate is 2 years from the creation date.
Is it possible to somehow increase it to, for example, 10 years?

image

Connection problem on OpenVPN 2.1.x client

Hello,
I noticed problems on the client wit hOpenVPN version 2.1.x
Example:
OpenVPN version 2.1.3 i486-pc-linux-gnu [SSL] [ILO2] [EPOLL] [PKCS11] [MH] [PF_INET6] [eurephia] built on Oct 21 2010

The solution could be to update the OpenVPN client, but this is not always possible.

In the case of using OpenVPN kylemann/openvpn it works without problems, even on version 2.1.3

logs from OpvenVPN server:

<CLIENT_PUBLIC_IP>:1194 SIGUSR1[soft,tls-error] received, client-instance restarting
<CLIENT_PUBLIC_IP>:1194 TLS Error: TLS handshake failed
<CLIENT_PUBLIC_IP>:1194 TLS Error: TLS object -> incoming plaintext read error
<CLIENT_PUBLIC_IP>:1194 TLS_ERROR: BIO read tls_read_plaintext error
<CLIENT_PUBLIC_IP>:1194 OpenSSL: error:0A000102:SSL routines::unsupported protocol
<CLIENT_PUBLIC_IP>:1194 TLS error: Unsupported protocol. This typically indicates that client and server have no common TLS version enabled. This can be caused by mismatched tls-version-min and tls-version-max options on client and server. If your OpenVPN client is between v2.3.6 and v2.3.2 try adding tls-version-min 1.0 to the client configuration to use TLS 1.0+ instead of TLS 1.0 only
<CLIENT_PUBLIC_IP>:1194 TLS: Initial packet from [AF_INET]<CLIENT_PUBLIC_IP>:1194, sid=7b5cc07e 7b003d07
<CLIENT_PUBLIC_IP>:1194 TLS Error: Unroutable control packet received from [AF_INET]<CLIENT_PUBLIC_IP>:1194 (si=3 op=P_CONTROL_V1)
<CLIENT_PUBLIC_IP>:1194 TLS Error: Unroutable control packet received from [AF_INET]<CLIENT_PUBLIC_IP>:1194 (si=3 op=P_CONTROL_V1)
<CLIENT_PUBLIC_IP>:1194 TLS Error: Unroutable control packet received from [AF_INET]<CLIENT_PUBLIC_IP>:1194 (si=3 op=P_CONTROL_V1)
<CLIENT_PUBLIC_IP>:1194 TLS Error: Unroutable control packet received from [AF_INET]<CLIENT_PUBLIC_IP>:1194 (si=3 op=P_CONTROL_V1)
<CLIENT_PUBLIC_IP>:1194 SIGUSR1[soft,tls-error] received, client-instance restarting
<CLIENT_PUBLIC_IP>:1194 TLS Error: TLS handshake failed
<CLIENT_PUBLIC_IP>:1194 TLS Error: TLS object -> incoming plaintext read error
<CLIENT_PUBLIC_IP>:1194 TLS_ERROR: BIO read tls_read_plaintext error
<CLIENT_PUBLIC_IP>:1194 OpenSSL: error:0A000102:SSL routines::unsupported protocol
<CLIENT_PUBLIC_IP>:1194 TLS error: Unsupported protocol. This typically indicates that client and server have no common TLS version enabled. This can be caused by mismatched tls-version-min and tls-version-max options on client and server. If your OpenVPN client is between v2.3.6 and v2.3.2 try adding tls-version-min 1.0 to the client configuration to use TLS 1.0+ instead of TLS 1.0 only
<CLIENT_PUBLIC_IP>:1194 TLS: Initial packet from [AF_INET]<CLIENT_PUBLIC_IP>:1194, sid=6ad261b0 5fc8a94e
<CLIENT_PUBLIC_IP>:1194 TLS Error: Unroutable control packet received from [AF_INET]<CLIENT_PUBLIC_IP>:1194 (si=3 op=P_CONTROL_V1)
<CLIENT_PUBLIC_IP>:1194 TLS Error: Unroutable control packet received from [AF_INET]<CLIENT_PUBLIC_IP>:1194 (si=3 op=P_CONTROL_V1)
<CLIENT_PUBLIC_IP>:1194 TLS Error: Unroutable control packet received from [AF_INET]<CLIENT_PUBLIC_IP>:1194 (si=3 op=P_CONTROL_V1)
<CLIENT_PUBLIC_IP>:1194 TLS Error: Unroutable control packet received from [AF_INET]<CLIENT_PUBLIC_IP>:1194 (si=3 op=P_CONTROL_V1)

openvpn not starting: Extension MASQUERADE revision 0 not supported

When starting openvpn-ui from scratch, both containers are created, but the openvpn container keeps restarting. When I select Configuration > OpenVPN Server, I got a blank page. In the log file of the openvpn container I see:

net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
Configuring iptables...
NAT for OpenVPN clients
Warning: Extension MASQUERADE revision 0 not supported, missing kernel module?
iptables v1.8.10 (nf_tables): Could not fetch rule set generation id: Invalid argument

Is this a known issue, is there a workaround?
Thanks for helping out

easy RSA vars, client/server default config files

Hi,

Thank you for this neat project :)

  1. I would like to set the easy-rsa defaults but no matter where I put the easy-rsa.vars and the vars files (config/pki directories), the UI shows the default ones that arrived with the container image

  2. When creating a user configuration file from the UI, none of the easy RSA values from either ./config/easy-rsa.vars, ./config/vars or ./pki/vars are added to the certificate (it's the same with the server's certificate, only the CN field contains information)

  3. Same with the server/client.conf files, unless I use the UI to change, f.e., the server's IP/FQDN, the files I placed in the "config" directory don't get used

  4. I would also, if possible, ask for tags other than "latest" so I'll be able to use specific releases in my setup

I would like to automate this with my own values, perhaps I am using this tool(s) wrong and need some guidance

Thanks

Connect problem

Snipaste_2024-05-03_22-10-05

After deploying the docker containers for openvpn-server and openvpn-ui, everything works normally up to the point of creating certificates and connecting to the openvpn server. However, after connecting to the server, I cannot access the external network, only internal network communication is possible.

Here is my connection log, which looks normal. Below are the container's routing table and iptables rules.
Snipaste_2024-05-03_22-11-52

How can I view detailed client connection reports and observe the entire connection process?

Example from docker-compose.yml does not work properly

Hello,
I tried to build docker containers from docs/docker-compose.yml however it does not work properly for me.

OS: Debian 10

Pulling from d3vilh/openvpn-ui-arm32v7 executed correctly, then when building openvpn I get the error like:

Cannot locate specified Dockerfile: Dockerfile

After adding dockerfile, problem occurs at step 5/11:

Step 5/11 : RUN apk --no-cache --no-progress upgrade && apk --no-cache --no-progress add bash bind-tools curl wget ip6tables iptables openvpn easy-rsa
 ---> [Warning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
 ---> Running in 412f6d3d663e
exec /bin/sh: exec format error
ERROR: Service 'openvpn' failed to build: The command '/bin/sh -c apk --no-cache --no-progress upgrade && apk --no-cache --no-progress add bash bind-tools curl wget ip6tables iptables openvpn easy-rsa' returned a non-zero code: 1

I also tried installing docker image kylemann/openvpn separately, however I don't know how to hook it up to openvpn-ui

Docker file looks like ready to use for Alpine, not for Debian.
Will it there be some prepared version under Debian?

Can openvpn-ui be hooked up to openvpn from another container such as the one from kylemann?

Prometheus endpoint

Hello and thank you for all this great great work!!!! :)

I was wondering if it's possible to have a Prometheus endpoint that will either enable the openvpn-exporter to connect to it and do its magic or have the endpoint itself publish the metrics, we're currently monitoring for up (obviously :D) and number of online users (very small deployment, not sure what else is needed or can be published)
I was thinking that for the UI maybe we can have the number of users, certificates (revoked or otherwise) and such

It would be great if this can be made possible

Thanks again

Issue with creating certificate

Hello,

When setting the EasyRSA with a value that has a special character, in this case a period, creation of certificate fails
I've added the "Ltd." to my EasyRSA_REQ_ORG and now when I try to create a certificate I get "Exit status 1"
The logs show this message

openvpn-ui | 2023/12/06 12:07:51.533 [D] [certificates.go:157] /bin/bash: line 1: export: Ltd.': not a valid identifier`

Thanks

Server config location issue

On most default installation the server.conf location is /etc/openvpn. The openvpn-ui code requires hardwired a /config/server.conf directory in controllers/ovconfig.go.
This should be parametrized so default installation will become supported.
The location of the client.conf might also be a parameter.

Standalone Install Username/Password

I just tried doing the standalone install a few times and every time after following the instructions I cannot login. I use the export commands for both username and password but cannot get in.

Reverse-proxy support

Hello,

Thank you for your improvements to the original. I needed support for complete ovpn files that include the certs and this fork provided that. I struggled quite a bit though and have some related questions:

  • How do I configure the application to reply to domain.tld/path instead of localhost? The problem is that I use Traefik reverse proxy and even if I strip the path prefix via middleware, the application redirects to /login which is then not recognized.
# curl https://xxx.zapto.org/openvpn-ui -IkL
HTTP/2 302 
content-type: text/html; charset=utf-8
date: Wed, 01 Feb 2023 01:40:45 GMT
location: /login
set-cookie: beegosessionID=7494a3c8133407e8e304d2d9dabcc0a6; Path=/; HttpOnly

HTTP/2 400 
date: Wed, 01 Feb 2023 01:40:45
user-agent: COOLWSD HTTP Agent 22.05.9.3
content-length: 0

  • I used your image from docker hub because I couldn't build the app, what are the steps?
  • docker-entrypoint.sh seems to be missing and I had to find it in git hostory. I see there is a template in the repo but still, don't know how to build the app.
  • container crashed due to missing vars file, had to add that, most likely because of the above?

Client configuration menu issues

Hi,

When I add/change a setting in the client Configuration=>OpenVPN Client section, doesn't matter if I delete the value, it stil lshows when I come back to the page or create a new certificate

I tried initializing all, dropping the DB, nothing helped so, as this is a test instance, I dropped the containers, cleaned the relevant directories and started the containers again

I also saw this message in the OpenVPN container logs
openvpn | 2023-12-06 12:57:25 Note: Treating option '--ncp-ciphers' as '--data-ciphers' (renamed in OpenVPN 2.5).

Thanks

  • Let me know if you'd like further issues combined into one issue or separated issues
    Thanks again for all your work with this

duplicate-cn

hello
i have problem with duplicate-cn
for use same certs more users.
i have tested.
connect device1.. after i try connect other one disconect device1 and connect device2.

never connected both.

or maybe if have config have more devices 1 user.

127.0.0.1:53 misbehaving

Hi,

I have a vague recollection of this being resolved somehow but for the life of me, I can't remember how :(

image
image

Thanks

Problem connection dynamic.pool (v0.8)

Hello i have small problem in my debian server
maybe need a help.
i'm create users from UI. only username/password
/root/openvpn/staticclients/myVPNUSER
ifconfig-push dynamic.pool 255.255.255.0

server.conf are default by you.

other one question.
how to update V0.9 without lost my data ?

Feature Request: Integrate SSO with Authentik

Hi there,

First, thank you for the incredible work on this project. The graphical interface for OpenVPN is incredibly useful, and the existing user management system is quite helpful.

However, I believe the user management experience could be further enhanced by integrating a Single Sign-On (SSO) solution, such as Authentik. Here are a few reasons why I think this would be beneficial:

  1. Improved Security: SSO solutions like Authentik offer advanced security features such as multi-factor authentication (MFA) and centralized user management, reducing the risk of security breaches.
  2. Better User Experience: Users can log in with their existing credentials, eliminating the need to remember multiple usernames and passwords.
  3. Simplified Administration: With SSO, administrators can manage user access and permissions more efficiently, ensuring that only authorized users have access to the VPN.

Suggested Implementation:

  • Integrate the Authentik SSO provider into the existing user management system.
  • Allow administrators to configure SSO settings via the graphical interface.
  • Provide documentation and examples for setting up and using Authentik with the project.

I believe that this integration would greatly benefit many users and administrators by providing a more secure and user-friendly authentication method.

Thank you for considering this feature request. Please let me know if I can provide any further details or assist in any way.

Best regards,
Gauthier

Enhance OpenVPN Experience with Seamless MFA During Network Transitions

Goal
The primary objective is to refine the user experience with OpenVPN, particularly in the context of Multi-Factor Authentication (MFA). We aim to establish a more seamless transition that doesn't necessitate re-authentication when there's a change in the network environment. This enhancement is especially critical in mobile scenarios where network switches are frequent and inevitable.

Problem Statement
Currently, users face a significant challenge when their network environment changes while connected to an OpenVPN server with MFA enabled. For instance, consider a scenario where a user is connected to the VPN over a home WiFi network. As soon as the user leaves the vicinity of their WiFi and their device switches to a mobile data, the VPN connection requires re-authentication. This process does not just introduce inconvenience but often fails, leading to disruptions in connectivity and secure access.

Use Case
This issue predominantly affects mobile users who frequently transition between different networks (e.g., from WiFi to mobile data or between different WiFi networks). The need to manually re-authenticate each time not only hampers productivity but also affects the overall user experience negatively.

Proposed Solution
Using session token mechanism. When a user successfully authenticates with MFA, we generate a session token (a unique, temporary identifier) that is valid for a specific duration (would be nice to set it in the configuration). This token is then used to validate subsequent connections without requiring MFA again, as long as the token is still valid.

Potential Benefits
Implementing this feature could significantly enhance the user experience by providing a more stable and uninterrupted connection, reducing the need for technical support related to connection issues, and ensuring secure access remains consistent regardless of the network environment.

Multiple net.ipv4.ip_forward = 1 in /etc/sysctl.conf

Docker-entrypoint.sh adds net.ipv4.ip_forward = 1 to the /etc/sysctl.conf every container reboot, as shown on the log below.

EasyRSA path: /usr/share/easy-rsa OVPN path: /etc/openvpn
PKI already set up.
Following EASYRSA variables were set during CA init:
 EASYRSA_DN "org"
 EASYRSA_REQ_COUNTRY "UA"
 EASYRSA_REQ_PROVINCE "KY"
 EASYRSA_REQ_CITY "Kyiv"
 EASYRSA_REQ_ORG "SweetHome"
 EASYRSA_REQ_EMAIL "[email protected]"
 EASYRSA_REQ_OU "MyOrganizationalUnit"
 EASYRSA_REQ_CN "OpenVPNServer"
 EASYRSA_KEY_SIZE 2048
 EASYRSA_CA_EXPIRE 3650
 EASYRSA_CERT_EXPIRE 825
 EASYRSA_CERT_RENEW 30
 EASYRSA_CRL_DAYS 180
Configuring networking rules...
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
net.ipv4.ip_forward = 1
Configuring iptables...
NAT for OpenVPN clients

Standalone installation pki error

[E] [certificates.go:127] open /etc/openvpn//pki/index.txt: no such file or directory
[E] [certificates.go:116] open /etc/openvpn/pki/index.txt: no such file or directory

[E] [ovclientconfig.go:42] open /etc/openvpn/config/client.conf: no such file or directory

how can i change location at /etc/openvpn/easy-rsa/pki (and)
/etc/openvpn/ccd/client.conf

Please Help

EASY-RSA feature request, UI container restart not working properly and administrative port for the OpenVPN container

Hello again :)

  • I would like to suggest a feature, if possible that the openvpn-ui contaienr, upon initialization would either read the vars file in config or the pki directories instead of having to use the UI for that (will save me a gazillion of time, if possible :) )

  • When clicking on the "Restart UI" button from maintenance, the openvpn-ui contaienr doesn't restart, it stops but doesn't restart

  • In the example docker-compose.yml please add port 2080 in the openvpn section for administrative purposes

Thanks a lot for this project

./openvpn-ui: cannot execute: required file not found

Hi,

When trying to setup openvpn-server openvpn-ui together using docker-compose-openvpnui.yml, openvpn-ui service keeps restarting. Logs are showing:

Init. OVPN path: /etc/openvpn                                                                                                                    
Starting OpenVPN UI!                                                                                                                             
start.sh: line 33: ./openvpn-ui: cannot execute: required file not found   

What can be wrong in the configuration ? It would be good to get a better error message.

Another question, why we need priviledged: true option and mounting var docker volume for UI server?
Thanks!

How to refresh certificates - for server and client?

Hello,
On the /certificates page we have a preview of the certificates. There is an Expiration date after which the client/server will probably not have access to the VPN. I'm referring to these dates:

image

How do you refresh these certificates? Is it possible to do it somehow without breaking the current server<->client connection e.g. by swapping .ovpn config on client and server?

can't find ./openvpn-ui

Would you like to install Beego v2? (y/n) y
Installing BeeGo v2
github.com/beego/bee/v2: go install github.com/beego/bee/v2: mkdir /root/go/bin/: file exists
Would you like to build OpenVPN-UI and qrencode binaries? (y/n) y
Installing OpenVPN-UI and qrencode
Cloning qrencode into build directory
fatal: destination path 'qrencode' already exists and is not an empty directory.
Building and packing OpenVPN-UI
standalone-install.sh: line 125: bee: command not found
standalone-install.sh: line 126: bee: command not found
Building qrencode
Moving qrencode to GOPATH
All done.

OpenVPN Client configuration (0.9.2)

hello i want from template 2 extra setting in .opvn file.
askpass UserAuth.file
log /etc/openvpn/openvpn.log

here no option add extra settings
image

directly from /root/openvpn/config/client.conf dont load the config.

also from panel config no load extra config
image

Deleting a revoked client brings to the 404 page

When attempting to delete a revoked client, the action redirects to a 404 error page. The deletion process works perfectly if the client is deleted immediately after revocation. However, if the page is refreshed before attempting to delete the client, it results in a 404 error page.

MFA

Hello,

Are you planning on adding MFA integration for OpenVPN?

Thanks

OpenVPN issue when missing /etc/openvpn/config/easy-rsa.vars

Hi,

When I start a new, clean, containers, with config directory as volume, I get this message

openvpn | cp: can't stat '/etc/openvpn/config/easy-rsa.vars': No such file or directory openvpn exited with code 1

Placing an empty file before starting the containers resolves this

Thanks

repository for d3vilh/openvpn-server Docker image

I have seen that all the documents contain the link to the docker image for d3vilh/openvpn-server, but didn't find the real repository for it.

Instead of having a link to the docker hub, its better to put the GitHub repository link and in the README.md of that repository put the badge to the docker hub for example:

Docker Image Version (latest semver)

The problem with change Issuer and DirName in <cert>

Hello,
I have a problem with chane for Issuer and DirName in <cert> in client .ovpn config
default:

Issuer: C=UA, ST=KY, L=Kyiv, O=Sweet Home, OU=My Organizational Unit, CN=Easy-RSA CA/[email protected]
DirName:/C=UA/ST=KY/L=Kyiv/O=Sweet Home/OU=My Organizational Unit/CN=Easy-RSA CA/[email protected]

changing :

  • docker compose
  • easy-rsa.vars
  • pki/vars

doesn't do anything - it's still the default

Clients certificates

thanks for your awesome job,

but when i download Clients certificates, I got this error reponse:

`This site can’t be reached

The webpage at http://127.0.0.1:8080/certificates/test might be temporarily down or it may have moved permanently to a new web address.
ERR_INVALID_RESPONSE`

Some error message could be found backend:

./easyrsa: 341: set: Illegal option -o echo
openvpn | Generate HMAC signature...
openvpn | Create certificate revocation list (CRL)...
openvpn | Using SSL: openssl OpenSSL 1.1.1 11 Sep 2018
openvpn | Using configuration from /opt/app/easy-rsa/pki/easy-rsa-160.sH7Gw1/tmp.EdSeKW
openvpn | ./easyrsa: 341: set: Illegal option -o echo
openvpn | Configuring networking rules...
openvpn | net.ipv4.ip_forward = 1
openvpn | Configuring iptables...
openvpn | NAT for OpenVPN clients
openvpn | Bad argument 'ovpn_trusted_subnet'
openvpn | Try 'iptables -h' or 'iptables --help' for more information.

Look forward to your answser..

standalone-install.sh FATAL 0004 exit status 1

...
Would you like to install OpenVPN-UI and qrencode? (y/n) y
Installing OpenVPN-UI and qrencode
Cloning qrencode into build directory
Cloning into 'qrencode'...
remote: Enumerating objects: 35, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 35 (delta 8), reused 31 (delta 8), pack-reused 0
Receiving objects: 100% (35/35), 26.88 KiB | 1.68 MiB/s, done.
Resolving deltas: 100% (8/8), done.
Building and packing OpenVPN-UI
2024/06/01 20:04:49.531 [D] init global config instance failed. If you do not use this, just ignore it. open conf/app.conf: no such file or directory
2024/06/01 20:04:49 INFO ▶ 0001 Getting bee latest version...
2024/06/01 20:04:49 INFO ▶ 0002 Your bee are up to date


| ___
| |/ / ___ ___
| ___ \ / _ \ / _
| |
/ /| /| /
_
/ _
| __| v2.1.0

├── GoVersion : go1.21.5
├── GOOS : linux
├── GOARCH : amd64
├── NumCPU : 4
├── GOPATH :
├── GOROOT : /usr/local/go
├── Compiler : gc
└── Date : Saturday, 1 Jun 2024
2024/06/01 20:04:50.110 [D] init global config instance failed. If you do not use this, just ignore it. open conf/app.conf: no such file or directory


| ___
| |/ / ___ ___
| ___ \ / _ \ / _
| |
/ /| /| /
_
/ _
| __| v2.1.0
2024/06/01 20:04:50 INFO ▶ 0001 Packaging application on '/home'...
2024/06/01 20:04:50 INFO ▶ 0002 Building application (home)...
2024/06/01 20:04:50 INFO ▶ 0003 Using: GOOS=linux GOARCH=amd64
package .: no Go files in /home
2024/06/01 20:04:50 FATAL ▶ 0004 exit status 1
Building qrencode
./standalone-install.sh: line 111: cd: build/qrencode: No such file or directory
cannot find package "main.go" in any of:
/usr/local/go/src/main.go (from $GOROOT)
/home/openvpn/go/src/main.go (from $GOPATH)
chmod: cannot access 'qrencode': No such file or directory
Moving qrencode to GOPATH
mv: cannot stat 'qrencode': No such file or directory
All done.

Unable to set OpenVPN Client config protocol to TCP via UI

Hello,

I'm trying out the stack here but seem to have run into a small bug. For some reason I'm unable to change the OpenVPN client protocol to TCP via the UI.

After changing "Proto" to "tcp" and clicking the Save Config button, the client.conf always retains "udp". If I manually edit the client.conf file to "tcp" I don't see the change updated in the UI form for Proto even after a container re-start/re-create.

Changing other parameters for for the client config seem to work and save properly (address, port, etc)

Thanks!

possible to use the UI on existing vpn server installation ?

i see that the project comes with its own docker image which i assume contains also the ovpn server part. but it is possible to use it on an existing environment that runs outside docker? and if so, should those 2 environments share the same filesystems or can the 2 run on separate machines (ie. gui on server 1 and ovpn legacy env on server 2 ) ?

cheers

Credits to authors

It would be really nice if initial authors of the code which is claimed here as yours, would be referenced.
For example:
https://github.com/bugsyb/openvpn-web-ui-docker-build
Which is effectively:
https://github.com/d3vilh/openvpn-ui/tree/main/build

And situations like maintainer entry replaced with your credentials with zero credit for others work. It is not only about my work, there's certainly many others who did a lot skipped and code is claimed as yours.

Just claiming others work as yours is no nice.

At the same time, all integrations put all together into one place is really good - thumbs up for that.

Is this to do with me having zsh I wonder. Can you work that into the standalone-install.sh ?

Building and packing OpenVPN-UI
./standalone-install.sh: line 103: go: command not found
./standalone-install.sh: line 104: go: command not found
./standalone-install.sh: line 106: bee: command not found
./standalone-install.sh: line 107: bee: command not found
Building qrencode
./standalone-install.sh: line 111: cd: build/qrencode: No such file or directory
./standalone-install.sh: line 112: go: command not found
chmod: cannot access 'qrencode': No such file or directory
Moving qrencode to GOPATH
./standalone-install.sh: line 115: go: command not found
mv: cannot stat 'qrencode': No such file or directory

Docker Compose Manual Install with Server + UI Issues and 2FA problems

Hi,

I've been installing with the Docker-Compose.yml file that includes the combined images for the openvpn-server and the openvpn-ui. My goal is to use the 2FA authenticator for security (with no passwords) using a single docker-compose.yml.

I've come across a number of issues, I've managed to fix manually but not sure where/if they need addressing in the the openvpn-server and or openvpn-ui. I'll document them here, and show you my workarounds.

  1. When running the container the first time it complaines the "easy-rsa.vars" files is mssing. The logging directs you to a fix, I believe this issue has been raised. I'm not sure this is a problem, as gives you the oppourtinuity to enter your server cert details correctly. Mentioned for completeness

  2. When running the container for the first time its creates a directory in the root file system called "fw-rules.sh". I believe this is suppose to be a file. I believe this is caused because when "docker" attempts to map to the internal "fw-rules.sh" because its doesnt exist internally it creates a "directory" in the exposed volume part. It may be better to have an "empty" "fw-rules.sh" in the docker image. When it creates a directory the docker-entrypoint.sh" fails an the server fails to start. To solve this issues the directory requires removing and a file put in its place (blank).

  3. OpenVPn Server/GUI started sucessfully. I then proceeded to switch to 2FA authenticated and configured a single user. After a restart the server failed to "restart". Looking at the logs in was complaining about a missing file: "opt/app/bin/oath.sh" configured in the server conf. Intially I though this configuration wasnt not required and removed from "server.conf", as the 2FA documentation does not show what these values should be, the image is truncated. When connecting a client the 2FA prompt came up and I was authenticated onto the server, however after a little bit of testing reliased that "No Authenticatation was taking place and this file was required".
    As a workaround I copied this file from the openvpnserver:repo /assets/oath.sh. For convience I placed it in my "/config/oath.sh" directory and mapped this to the server.conf to this location. On my next login attempt the authenticated "failed" again this was due "oathtool" is not found. To resolve this issue I opened a shell into my docker vpn server console and ran the following command :
    "apk update && apk add --update-cache
    bash
    easy-rsa
    curl
    jq
    oath-toolkit-oathtool "
    taken from the "DockerFile", once ran this seems to add the oathtool to the path.

After restarting the server I've managed to correctly logon with 2FA, which correctly authenticates the server.

On checking the openvpn-server repo, I can see in the docker build that the "oath.sh" is not copied, but it does appears to install oathtool. I'm not sure if my issues at 3) were caused by the early issue at 1) 2) not completing the start script fully possible?

Hope this is useful. Thanks for the great work,

Phil.

How to use fw-rules.sh?

Hello,
I could not find information anywhere regarding the configuration of fw-rules.sh ~/openvpn/fw-rules.sh

how can I configure this so that clients do not have contact with each other and at the same time have access to the Internet?

Some example was described here

But I don't know if there is something I need to do on the client side, and whether it is the same running this script?

I think that, it's strange to add iptables on the OpenVPN server, because I can't access openvpn clients from the server.

/etc/openvpn/server.conf issue

Hi,

Thank you for all the latest updates, however, I was not aware that the server also got release versions and used the latest with ui 0.9.4.1 and now I'm in a bit of a mess :)

When using "- ./server.conf:/etc/openvpn/server.conf" as the example in docker-compose.yml shows, it creates an empty directory
Touching an empty file and mounting it as a volume doesn't have the configuration written to it
The only thing that worked was commenting out the "server.conf" line from the docker-compose.yml, let the container start and create the server.conf, down everything, and uncomment out the "server.conf" line, which means, I'll have to save the server.conf and copy it over to all my future setups

Eventually, what I did was this

`services:
openvpn:
container_name: openvpn
image: d3vilh/openvpn-server:0.5.1
privileged: true
ports:
- 1194:1194/udp
- 2080:2080
environment:
TRUST_SUB: 10.0.70.0/24
GUEST_SUB: 10.0.71.0/24
HOME_SUB: 192.168.88.0/24
volumes:
- ./:/etc/openvpn
- ./config:/etc/openvpn/config - only holds easy-rsa.vars file
- ./log:/var/log/openvpn
- ./fw-rules.sh:/opt/app/fw-rules.sh
cap_add:
- NET_ADMIN
restart: unless-stopped

openvpn-ui:
container_name: openvpn-ui
image: d3vilh/openvpn-ui:0.9.5.1
environment:
- OPENVPN_ADMIN_USERNAME=admin
- OPENVPN_ADMIN_PASSWORD=gagaZush
privileged: true
ports:
- 8080:8080/tcp
volumes:
- ./:/etc/openvpn
- ./db:/opt/openvpn-ui/db
- ./pki:/usr/share/easy-rsa/pki
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped`

So, all is working again and thank yo uagain for all your hard work on this

Adaptation request

Hello, which openvpn server image is this openvpn ui compatible with? I tried using the container for kylmanna/openvpn images and found that it is compatible. Looking forward to your reply

Email issue and request

Hi,

  • When using the "Send email, I only get some information about the certificate, not the detailed information I get when I click on the Copybutton, which incidentally, doesn't copy the QR code2FA Name: Blah
    Certificate Name:
    Blah
    Status: Valid
    Expiration Time: 2026-03-10 12:16
    Revoke Time: Not Revoked
    IP Address: dynamic.pool
    Serial: Blah
    Registered e-mail: [email protected]
    Registered Country: Blah
    Registered State/Region: Blah
    Registered City: Blah
    Registered Organisation: Blah
    Registered Unit: Blah
    Two Factor Authorisation (2FA) QR Code:

                      `
    
  • Can you add an option to email the configuration to the end user, as well?

Thanks

install script

I wondered if an install script would be useful? I am sure thats something I could easily get my head around if you were interested? For people not running docker

Configuration -->Client webpage error

OS: LXC Debian12 (and running docker in LXC)

Hi,

I use docker compose to deploy openvpn-ui standalone because I already installed an OpenVPN Server (https://github.com/Nyr/openvpn-install)

When I try to access /ov/clientconfig (Click the top menu: Configuration --> OpenVPN Client), I got errors and the webpage is empty.

openvpn-ui  | [ORM]2024/04/28 06:33:46  -[Queries/default] - [  OK / db.QueryRow /     0.0ms] - [SELECT `id`, `login`, `is_admin`, `name`, `email`, `password`, `lastlogintime`, `created`, `updated` FROM `user` WHERE `id` = ? ] - `1`
openvpn-ui  | [ORM]2024/04/28 06:33:46  -[Queries/default] - [  OK / db.QueryRow /     0.0ms] - [SELECT `id`, `profile`, `m_i_address`, `m_i_network`, `o_v_config_path`, `easy_r_s_a_path`, `created`, `updated` FROM `settings` WHERE `profile` = ? ] - `default`
openvpn-ui  | 2024/04/28 06:33:46.914 [E] [ovclientconfig.go:42]  open /etc/openvpn/config/client.conf: no such file or directory
openvpn-ui  | 2024/04/28 06:33:46.915 [D] [template.go:70]  template Execute err: template: ovclient.html:52:33: executing "body" at <eq .Settings.FuncMode 0>: error calling eq: invalid type for comparison
openvpn-ui  | 2024/04/28 06:33:46.915 [E] [router.go:1246]  template: ovclient.html:52:33: executing "body" at <eq .Settings.FuncMode 0>: error calling eq: invalid type for comparison

Here is my docker-compose.yml

services:
    openvpn-ui:
       container_name: openvpn-ui
       image: d3vilh/openvpn-ui:latest
       environment:
           - OPENVPN_ADMIN_USERNAME=admin
           - OPENVPN_ADMIN_PASSWORD=password
       privileged: true
       ports:
           - "53445:8080/tcp"
       volumes:
           - /etc/openvpn/server:/etc/openvpn
           - /etc/openvpn/server/easy-rsa/pki:/etc/openvpn/pki 
           # I add this line because I found openvpn-ui want to access /etc/openvpn/pki but my pki store in a different path
           - ./db:/opt/openvpn-ui/db
           - /etc/openvpn/server/easy-rsa/pki:/usr/share/easy-rsa/pki
           - /var/run/docker.sock:/var/run/docker.sock:ro
       restart: always

Hope for your reply,
Regards. :)

White space in Registered City

Hi,

If I enter a value of two words, separated with a white space, the part after (including) the white space disappears

Thanks

Container restarting and I can't connect to UI of openvp-ui

After deploying the docker containers for openvpn-server and openvpn-ui, the containers are a status restarting.
#docker logs -f openvpn
Notice

'init-pki' complete; you may now create a CA or requests.

Your newly created PKI dir is:

  • /usr/share/easy-rsa/pki

Using Easy-RSA configuration:

  • undefined

EasyRSA path: /usr/share/easy-rsa OVPN path: /etc/openvpn
Setting up public key infrastructure...

Also I can't connect to openvpn-ui
#docker logs -f openvpn-ui

Init. OVPN path: /etc/openvpn
Starting OpenVPN UI!
Config file: conf/app.conf
table user already exists, skip
table settings already exists, skip
table o_v_config already exists, skip
table o_v_client_config already exists, skip
table easy_r_s_a_config already exists, skip
[ORM]2024/05/29 13:50:35 -[Queries/default] - [ OK / db.QueryRow / 0.0ms] - [SELECT id, login, is_admin, name, email, password, lastlogintime, created, updated FROM user WHERE name = ? ] - Administrator
2024/05/29 13:50:35.556 [D] [models.go:66] {1 true Administrator root@localhost $s2$16384$8$1$K7jKDSNqzVv23wDF9mAboziv$sXkbaZJERFdKMr7oIK8hW5U4B5xaHddm0Au+z/fpcfw= 0001-01-01 00:00:00 +0000 UTC 2024-05-29 11:32:12.49214737 +0000 UTC 2024-05-29 11:32:12.492148552 +0000 UTC}
[ORM]2024/05/29 13:50:35 -[Queries/default] - [ OK / db.QueryRow / 0.0ms] - [SELECT id, profile, m_i_address, m_i_network, o_v_config_path, easy_r_s_a_path, created, updated FROM settings WHERE profile = ? ] - default
2024/05/29 13:50:35.556 [D] [models.go:106] {1 default openvpn:2080 tcp /etc/openvpn /usr/share/easy-rsa 2024-05-29 11:32:12.49317661 +0000 UTC 2024-05-29 11:32:12.493177311 +0000 UTC}
[ORM]2024/05/29 13:50:35 -[Queries/default

Thank you to help me.

Bash script corrupts config files if VPN name clients has the same beginning

STR:

  1. Create "admin" client
  2. Create "admin123" client
  3. Create "admin12345" client
  4. Revoke "admin"

Result: index.txt file is broken - rmclient.sh has issue
Additionally, rmcert.sh is affected and cannot read properly CERT_SERIAL for such clients

POSSIBLE FIX:
rmclient.sh

Fix index.txt by removing everything after pattern "/name=$1" in the line
sed -i'.bak' "s/\/name=${1}\/.*//" /usr/share/easy-rsa/pki/index.txt

rmcert.sh

Define key serial number by keyname

STATUS_CH=$(grep -e ${1}$ -e${1}/ ${INDEX_PATH} | awk '{print $1}' | tr -d '\n')
if [[ $STATUS_CH = "V" ]]; then
    echo "Cert is VALID"
    CERT_SERIAL=$(grep ${1}/ ${INDEX_PATH} | awk '{print $3}' | tr -d '\n')
    echo "Will remove: ${CERT_SERIAL}"
else
    echo "Cert is REVOKED"
    CERT_SERIAL=$(grep ${1}$ ${INDEX_PATH} | awk '{print $4}' | tr -d '\n')
    echo "Will remove: ${CERT_SERIAL}"
fi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.