adamwalach / openvpn-web-ui

Web interface (with golang backend) for monitoring and administration of OpenVPN server
MIT License
673 stars 274 forks source link

Run on ARM/Raspberry #6

Open TacoScheltema opened 6 years ago

TacoScheltema commented 6 years ago

Hi, I've tried running this on a Raspberry but the docker instances keep restarting.

running docker logs openvpn shows the following error: standard_init_linux.go:195: exec user process caused "exec format error''

so I guess these dockers do not run on ARM. It would be great to be able to do so though. do you have any plans to add support for ARM? or maybe provide instructions on how to build it myself?

Kind regards, Taco Scheltema

bugsyb commented 4 years ago

Seems like this is amd64 (x86_64) image at OS level.

@adamwalach , would it be possible to get image released, best based on alpine? Ubuntu would work great or if you could provide some hints on what is that image - how to get it built - https://hub.docker.com/layers/awalach/openvpn-web-ui/latest/images/sha256-263d539faf6e7f40a6b4a092260b26ac0647c5cad62861406fda1f3e752f1e97?context=explore.

I can try to reverse engineer it from layers, but it is more work vs if you could provide some instructions as seems like your image is compilation of standard openvpn image (amd64) + templates with AdminLTE (amazingly compiled btw. thanks for great work).

Any hints would be great.

bugsyb commented 4 years ago

Small update: Managed to get Go and Bee in docker and to run app. This generated openvpn-web-ui binary and did run it with output as below. It all looks positive.

The missing part, where some help is needed - should it be run manually and keep it open or as daemon or maybe just expose one of the folders?

I'll keep digging, but some help would be appreciated.

UPDATE1: found "bee pack -exr='^vendor|^data.db|^build|^README.md|^docs'" - seems like am on good path to get that running as everything is in the package.

bee run -gendoc=true
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.10.0
2020/02/23 12:59:42 INFO     ▶ 0001 Using 'openvpn-web-ui' as 'appname'
2020/02/23 12:59:42 INFO     ▶ 0002 Initializing watcher...

2020/02/23 12:59:42 INFO     ▶ 0003 Generating the docs...
2020/02/23 12:59:42 SUCCESS  ▶ 0004 Docs generated!
2020/02/23 12:59:49 SUCCESS  ▶ 0005 Built Successfully!
2020/02/23 12:59:49 INFO     ▶ 0006 Restarting 'openvpn-web-ui'...
2020/02/23 12:59:49 SUCCESS  ▶ 0007 './openvpn-web-ui' is running...
create table `user` 
    -- --------------------------------------------------
    --  Table Structure for `github.com/adamwalach/openvpn-web-ui/models.User`
    -- --------------------------------------------------
    CREATE TABLE IF NOT EXISTS `user` (
        `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
        `login` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `name` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `email` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `password` varchar(32) NOT NULL DEFAULT '' ,
        `lastlogintime` datetime,
        `created` datetime NOT NULL,
        `updated` datetime NOT NULL
    );

create table `settings` 
    -- --------------------------------------------------
    --  Table Structure for `github.com/adamwalach/openvpn-web-ui/models.Settings`
    -- --------------------------------------------------
    CREATE TABLE IF NOT EXISTS `settings` (
        `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
        `profile` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `m_i_address` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `m_i_network` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `o_v_config_path` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `server_address` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `created` datetime NOT NULL,
        `updated` datetime NOT NULL
    );

create table `o_v_config` 
    -- --------------------------------------------------
    --  Table Structure for `github.com/adamwalach/openvpn-web-ui/models.OVConfig`
    -- --------------------------------------------------
    CREATE TABLE IF NOT EXISTS `o_v_config` (
        `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
        `profile` varchar(64) NOT NULL DEFAULT ''  UNIQUE,
        `port` integer NOT NULL DEFAULT 0 ,
        `proto` varchar(255) NOT NULL DEFAULT '' ,
        `ca` varchar(255) NOT NULL DEFAULT '' ,
        `cert` varchar(255) NOT NULL DEFAULT '' ,
        `key` varchar(255) NOT NULL DEFAULT '' ,
        `cipher` varchar(255) NOT NULL DEFAULT '' ,
        `keysize` integer NOT NULL DEFAULT 0 ,
        `auth` varchar(255) NOT NULL DEFAULT '' ,
        `dh` varchar(255) NOT NULL DEFAULT '' ,
        `server` varchar(255) NOT NULL DEFAULT '' ,
        `ifconfig_pool_persist` varchar(255) NOT NULL DEFAULT '' ,
        `keepalive` varchar(255) NOT NULL DEFAULT '' ,
        `max_clients` integer NOT NULL DEFAULT 0 ,
        `management` varchar(255) NOT NULL DEFAULT '' 
    );

[ORM]2020/02/23 12:59:50  -[Queries/default] - [  OK / db.QueryRow /     0.1ms] - [SELECT `id`, `login`, `name`, `email`, `password`, `lastlogintime`, `created`, `updated` FROM `user` WHERE `name` = ? ] - `Administrator`
[ORM]2020/02/23 12:59:50  -[Queries/default] - [  OK /     db.Exec /   192.3ms] - [INSERT INTO `user` (`id`, `login`, `name`, `email`, `password`, `lastlogintime`, `created`, `updated`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)] - `1`, `admin`, `Administrator`, `root@localhost`, `$s2$16384$8$1$WD0ICZsEdqCqyV8DKPtFravm$AtrYJW871T7OVCmofCqAoOWjydLvpXdzQc+oesNvSHk=`, `<nil>`, `2020-02-23 12:59:50.218804996 +0000 UTC`, `2020-02-23 12:59:50.218811163 +0000 UTC`
2020/02/23 12:59:50 [I] [models.go:65] Default admin account created 
[ORM]2020/02/23 12:59:50  -[Queries/default] - [  OK / db.QueryRow /     0.2ms] - [SELECT `id`, `profile`, `m_i_address`, `m_i_network`, `o_v_config_path`, `server_address`, `created`, `updated` FROM `settings` WHERE `profile` = ? ] - `default`
[ORM]2020/02/23 12:59:50  -[Queries/default] - [  OK /     db.Exec /   155.0ms] - [INSERT INTO `settings` (`profile`, `m_i_address`, `m_i_network`, `o_v_config_path`, `server_address`, `created`, `updated`) VALUES (?, ?, ?, ?, ?, ?, ?)] - `default`, `openvpn:2080`, `tcp`, `/etc/openvpn/`, `127.0.0.1`, `2020-02-23 12:59:50.412457518 +0000 UTC`, `2020-02-23 12:59:50.412465893 +0000 UTC`
2020/02/23 12:59:50 [I] [models.go:86] New settings profile created 
[ORM]2020/02/23 12:59:50  -[Queries/default] - [  OK / db.QueryRow /     0.4ms] - [SELECT `id`, `profile`, `port`, `proto`, `ca`, `cert`, `key`, `cipher`, `keysize`, `auth`, `dh`, `server`, `ifconfig_pool_persist`, `keepalive`, `max_clients`, `management` FROM `o_v_config` WHERE `profile` = ? ] - `default`
panic: reflect: call of reflect.Value.Int on string Value

goroutine 1 [running]:
reflect.Value.Int(...)
    /usr/local/go/src/reflect/value.go:986
github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm.(*dbBase).collectFieldValue(0x1011998, 0x10188c0, 0x109f5f0, 0x5acf20, 0x1108230, 0x199, 0x60401, 0xa172b0, 0x579a50, 0x10f2260, ...)
    /go/src/github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm/db.go:214 +0x194c
github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm.(*dbBase).collectValues(0x1011998, 0x10188c0, 0x5acf20, 0x1108230, 0x199, 0x1094300, 0x10, 0x10, 0x1100100, 0x10dfd48, ...)
    /go/src/github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm/db.go:92 +0x16c
github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm.(*dbBase).Insert(0x1011998, 0x6d3348, 0x10c2020, 0x10188c0, 0x5acf20, 0x1108230, 0x199, 0xa172b0, 0x0, 0x0, ...)
    /go/src/github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm/db.go:376 +0xb8
github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm.(*orm).Insert(0x10ee010, 0x5b73d0, 0x1108230, 0x1018801, 0x5acf20, 0x1108230, 0x199)
    /go/src/github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm/orm.go:166 +0x98
github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm.(*orm).ReadOrCreate(0x10ee010, 0x5b73d0, 0x1108230, 0x5fe61a, 0x7, 0x0, 0x0, 0x0, 0x56, 0x2, ...)
    /go/src/github.com/adamwalach/openvpn-web-ui/vendor/github.com/astaxie/beego/orm/orm.go:149 +0x3b0
github.com/adamwalach/openvpn-web-ui/models.createDefaultOVConfig()
    /go/src/github.com/adamwalach/openvpn-web-ui/models/models.go:116 +0x7c
github.com/adamwalach/openvpn-web-ui/models.init.0()
    /go/src/github.com/adamwalach/openvpn-web-ui/models/models.go:18 +0x20
v1-valux commented 3 years ago

Any progress here? Is there any alternative for an openvpn-gui for arm devices like raspberry (3 or 4)?

Cheers!

bugsyb commented 3 years ago

If you're asking me, then yes - I got it up and running on arm64.

MPapst commented 3 years ago

@bugsyb would you be willing to share your solution with us?

bugsyb commented 3 years ago

@MPapst - sure, happy to. Not that familiar with Github - but will need to do some reading, unless one could point me to good RTFM ;)

MPapst commented 3 years ago

@bugsyb the keyword is forking, maybe github offers a help site about that. The principle is that you create a fork of the repository in your own account, perform the changes and create a pull request back into this repository. Even if the owner does not merge the pull request, it will be visible for all.

bugsyb commented 3 years ago

Done as much as could so far (noob on Github)... Here are links and any suggestions on what's wrong/could be improved are more than welcome:

Hope this helps and in case of troubles let me know under repos and I'll try to fix it - didn't have time to test if all works as couldn't spun up separate docker host to play and not impact my prod (lack of time).

d3vilh commented 2 years ago

@bugsyb thank you for updating and spending time for ARMv8 port. Following your repo I managed to successfully build it for arm32v71. but it crashed on select o_v_config and throwing this exception, even before accessing the table: panic: reflect: call of reflect.Value.Int on string Value I think there is schema mismatch for openvpn-web-ui binary, but can't fix it as yet have no Go experience. Could you share any clue on how did you override this issue?

Thanks a lot in advance!

Update: As a WA I disable default profile configuration submit to o_v_config table by commenting out createDefaultOVConfig() function as part of init() in models.go:

func init() {
    initDB()
    createDefaultUsers()
    createDefaultSettings()
//  createDefaultOVConfig()
}

This will skip createDefaultOVConfig and web server starts normally.

bugsyb commented 2 years ago

@d3vilh , not sure if it helps and if not posted already, but I haven't such issue. Do you use similar in build process?

# Build golang & bee environment
docker build --platform="arm64" -f Dockerfile-beego -t local/beego-v8 -t local/beego-v8:latest .

Didn't build/rebuild it for quite some time and don't have time to go through the step by step hence only throwing some portions of files in hope it will give some clues.

FROM arm64v8/debian
WORKDIR /opt
EXPOSE 8080

# --no-install-recommends
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y easy-rsa
RUN chmod 755 /usr/share/easy-rsa/*
ADD assets/start.sh /opt/start.sh
ADD assets/generate_ca_and_server_certs.sh /opt/scripts/generate_ca_and_server_certs.sh
ADD assets/vars.template /opt/scripts/

ADD openvpn-web-ui.tar.gz /opt/openvpn-gui/
RUN rm -f /opt/openvpn-gui/data.db
ADD assets/app.conf /opt/openvpn-gui/conf/app.conf

# temporary for tests
ADD assets-override/dh2048.pem /etc/openvpn/
ADD assets-override/dh4096.pem /etc/openvpn/

CMD /opt/start.sh

On the UI src code - outside of what has been published, nothing else has been changed and it fresh copy of my mods to get that working.

bnhf commented 2 years ago

A few things to add here:

I've been working on a version of this web-ui specifically for OpenVPN TAP servers (non-Docker, due to bridging), running on amd64 architectures -- but using PiVPN as the script to setup the initial server (works for Debian and Ubuntu on amd64). It's been working well, and I'm happy with the end result. There are still a couple of features that I'm planning to integrate from other forks in this repository.

So I thought, I'd try building a Docker image for the Raspberry Pi in ARMv7 mode, expecting there would be numerous changes -- but there were almost none! A couple of syntax tweaks having to do with the underlying OS, which I fixed with constructions that should work everywhere.

Everything has been updated internal to the application, as well as supporting the latest version of OpenVPN and EasyRSA. It's integrated with PiVPN, so you can use PiVPN commands from the command line as well. The primary update to the interface is the change to a dark theme:

Screenshot 2022-02-23 161541

Screenshot 2022-02-23 161617

Screenshot 2022-02-23 161759

screenshot-raspberrypi5_8080-2022 02 23-16_26_15

screenshot-raspberrypi5_8080-2022 02 23-16_18_17