d3vilh / openvpn-ui

Web User Interface for OpenVPN
MIT License
256 stars 57 forks source link

Configuration -->Client webpage error #65

Closed Houiin closed 4 months ago

Houiin commented 5 months ago

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. :)

d3vilh commented 5 months ago

Hi @Houiin, Apologise for the delay (replied finally :) Interesting bug, UI trying to create temporary client config file, but $OPENVPN/config/client.conf is missed in your setup. You could try to create this file on your host server in /etc/openvpn/server/config/client.conf and it should work fine.

mkdir -p /etc/openvpn/server/config && touch /etc/openvpn/server/config/client.conf

In this case file path is already part of first volume from your docker-compose.yml, so no changes is needed in docker-compose file.

d3vilh commented 4 months ago

You could go with the latest versions of openvpn-server and openvpn-ui images from the DockerHub, where this problem was fixed.

Thank you :)