sebgl / htpc-download-box

Sonarr / Radarr / Jackett / NZBGet / Deluge / OpenVPN / Plex
1.98k stars 322 forks source link

VPN not configuring #28

Open harphere opened 4 years ago

harphere commented 4 years ago

Hello @sebgl , first of all thank you for this project, it is exactly what I was looking for.

After following all of your instructions, I cannot overcome this VPN error:

vpn | grep: /vpn/vpn.conf: No such file or directory vpn | ERROR: VPN CA cert missing! vpn | Options error: In [CMD-LINE]:1: Error opening configuration file: /vpn/vpn.conf vpn | Use --help for more information. vpn | ERROR: VPN not configured! I am using PIA CA-Vancouver server, renamed the .ovpn to vpn.conf, setup the username/password file and set my ${ROOT}/config/vpn.

I triple checked the .yaml and your instructions but it just does not want to work. I am hoping you or someone else can help me out here.

Much appreciated.

sebgl commented 4 years ago

@nickelnine were you able to make any progress? Does it work with other VPN configuration/location?

pherris commented 4 years ago

@sebgl I'm also experiencing the same issue.

vagrant@ubuntu-bionic:~/htpc-download-box$ sudo docker-compose restart vpn && sudo docker-compose logs -f vpn
Restarting vpn ... done
Attaching to vpn
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | ERROR: VPN CA cert missing!
vpn            | grep: /vpn/vpn.conf: No such file or directory
vpn            | Options error: In [CMD-LINE]:1: Error opening configuration file: /vpn/vpn.conf
vpn            | Use --help for more information.
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | grep: /vpn/vpn.conf: No such file or directory
vpn            | ERROR: VPN CA cert missing!
vpn            | Options error: In [CMD-LINE]:1: Error opening configuration file: /vpn/vpn.conf
vpn            | Use --help for more information.
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | grep: /vpn/vpn.conf: No such file or directory
vpn            | ERROR: VPN CA cert missing!
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | grep: /vpn/vpn.conf: No such file or directory
vpn            | ERROR: VPN CA cert missing!
vpn            | Options error: In [CMD-LINE]:1: Error opening configuration file: /vpn/vpn.conf
vpn            | Use --help for more information.
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | grep: /vpn/vpn.conf: No such file or directory
vpn            | ERROR: VPN CA cert missing!
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!
vpn            | ERROR: VPN CA cert missing!
vpn            | grep: /vpn/vpn.conf: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ls: /vpn/*: No such file or directory
vpn            | ERROR: VPN not configured!`

I tried a few tweaks to the docker-compose.yml with a restart of vpn but no luck:

  vpn:
    container_name: vpn
    image: dperson/openvpn-client:latest
    cap_add:
      - NET_ADMIN # required to modify network interfaces
    restart: unless-stopped
    devices:
      - /dev/net:/dev/net:z # tun device
    volumes:
      - ${ROOT}/config/vpn:/vpn # OpenVPN configuration
    security_opt:
      - label:disable
    ports:
      - 8112:8112 # port for deluge web UI to be reachable from local network
    command: '-f "" -r 192.168.1.0/24' # enable firewall and route local network traffic

I noticed the following permissions (which are probably right):

-rw-r--r-- 1 vagrant vagrant  869 Oct 22 16:06 crl.rsa.2048.pem
-rw-r--r-- 1 vagrant vagrant 2025 Oct 22 16:06 ca.rsa.2048.crt
-rw-r--r-- 1 vagrant vagrant   21 Jan 19 04:07 vpn.auth
-rw-rw-r-- 1 vagrant vagrant  581 Mar 21 04:17 vpn.conf

but I tried anyway with 0755 but no luck with that either. Really seems to be a problem with container being able to access those files. Possibly a permissions issue with Vagrant (thats my approach, with OSX and an external HD).

The only other change I've made is to map the mounted drive to the vagrant user/group: config.vm.synced_folder "/Volumes/BACKUPS/", "/media/external", owner: 'vagrant', group: 'vagrant'

pherris commented 4 years ago

Something with the volume mounting in the container via docker-compose is off. I tried a bunch of variants with the Dockerfile from the VPN repo and they all had access to the correct files, but when I looked at the container running with docker-compose, they were not present:

vagrant@ubuntu-bionic:~/htpc-download-box$ sudo docker exec -it 3e999b50143f /bin/bash
bash-5.0# ls /vpn
bash-5.0# ls

All of the following commands resulted with something like:

vagrant@ubuntu-bionic:~/htpc-download-box$ sudo docker exec -it 938ab310c47263e4ed846c289647b4a05b09bb8b18c4a631879ef5767c50c19c /bin/bash
bash-5.0# ls /vpn
ca.rsa.2048.crt   crl.rsa.2048.pem  vpn.auth          vpn.conf

commands:

sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn2 -v /media/external/config/vpn:/vpn -d dperson/openvpn-client -v 'vpn.server.name;username;password'

sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn2 -v /media/external/config/vpn:/vpn -d dperson/openvpn-client:latest -v 'vpn.server.name;username;password'

sudo docker run -it --cap-add=NET_ADMIN --name vpn3 -v /media/external/config/vpn:/vpn -d dperson/openvpn-client:latest -v 'vpn.server.name;username;password'

sudo docker run -it --cap-add=NET_ADMIN --name vpn4 -v /dev/net:/dev/net:z -v /media/external/config/vpn:/vpn -d dperson/openvpn-client:latest -v 'vpn.server.name;username;password'

sudo docker run -it --cap-add=NET_ADMIN --name vpn5 -v /dev/net:/dev/net:z -v /media/external/config/vpn:/vpn -d dperson/openvpn-client:latest -v 'vpn.server.name;username;password'

sudo docker run -it --cap-add=NET_ADMIN --name vpn5 --security-opt label:disable -v /dev/net:/dev/net:z -v /media/external/config/vpn:/vpn -d dperson/openvpn-client:latest -v 'vpn.server.name;username;password'

sudo docker run -it --cap-add=NET_ADMIN --name vpn6 --security-opt label:disable -v /dev/net:/dev/net:z -v /media/external/config/vpn:/vpn -d dperson/openvpn-client:latest -v 'vpn.server.name;username;password' -p 8112:8112

sudo docker run -it --cap-add=net_admin --name vpn7 --security-opt label:disable -v /dev/net:/dev/net:z -v /media/external/config/vpn:/vpn -d dperson/openvpn-client:latest -v 'vpn.server.name;username;password' -p 8112:8112

sudo docker run -it --cap-add=net_admin --name vpn8 --security-opt label:disable -v /media/external/config/vpn:/vpn -v /dev/net:/dev/net:z -d dperson/openvpn-client:latest -v 'vpn.server.name;username;password' -p 8112:8112
pherris commented 4 years ago

My issue was a path problem - I was looking at the wrong directory - sorry to thread hijack :)