d3vilh / openvpn-server

Fast Docker container with OpenVPN Server living inside.
MIT License
39 stars 21 forks source link

Error opening configuration file: /etc/openvpn/server.conf #16

Closed ohmex closed 1 month ago

ohmex commented 4 months ago

Hello, I am facing this issue with "openvpn-server", I can get it to work, below are some logs.

contents of directory

root@ubuntu:/opt/vpn# ls
clients  config  db  docker-compose.yaml  fw-rules.sh  log  pki  server.conf  staticclients

docker ps

CONTAINER ID   IMAGE                          COMMAND                  CREATED       STATUS          PORTS                                            NAMES
b2b1dd1c13d9   d3vilh/openvpn-ui:latest       "/bin/sh -c /opt/sta…"   2 hours ago   Up 2 hours      0.0.0.0:8080->8080/tcp                           openvpn-ui
9443a116c23d   d3vilh/openvpn-server:latest   "/bin/sh -c ./docker…"   2 hours ago   Up 21 seconds   0.0.0.0:1194->1194/udp, 0.0.0.0:2080->2080/tcp   openvpn

installed image

root@ubuntu:/opt/vpn# docker inspect --format='{{json .Config.Labels}}' d3vilh/openvpn-server:latest
{"maintainer":"Mr.Philipp <d3vilh@github.com>","version":"0.5.1"}

container logs

2024-03-01T20:38:41.392709315Z net.ipv4.ip_forward = 1
2024-03-01T20:38:41.392719985Z net.ipv4.ip_forward = 1
2024-03-01T20:38:41.392723952Z net.ipv4.ip_forward = 1
2024-03-01T20:38:41.392727890Z net.ipv4.ip_forward = 1
2024-03-01T20:38:41.392731897Z net.ipv4.ip_forward = 1
2024-03-01T20:38:41.392786018Z Configuring iptables...
2024-03-01T20:38:41.392793112Z NAT for OpenVPN clients
2024-03-01T20:38:41.394880076Z Blocking ICMP for external clients
2024-03-01T20:38:41.396402424Z Blocking internal home subnet to access from external openvpn clients (Internet still available)
2024-03-01T20:38:41.397418124Z No additional firewall rules to apply.
2024-03-01T20:38:41.397427792Z IPT MASQ Chains:
2024-03-01T20:39:06.429454428Z MASQUERADE  all  --  10.0.70.0/24         anywhere            
2024-03-01T20:39:11.435063195Z MASQUERADE  all  --  10.0.71.0/24         anywhere            
2024-03-01T20:39:11.435285060Z IPT FWD Chains:
2024-03-01T20:39:11.436605409Z        0        0 DROP       1    --  *      *       10.0.71.0/24         0.0.0.0/0            icmptype 8
2024-03-01T20:39:11.436735364Z        0        0 DROP       1    --  *      *       10.0.71.0/24         0.0.0.0/0            icmptype 0
2024-03-01T20:39:11.436747828Z        0        0 DROP       0    --  *      *       10.0.71.0/24         192.168.88.0/24     
2024-03-01T20:39:11.437100397Z Start openvpn process...
2024-03-01T20:39:11.438876781Z Options error: In [CMD-LINE]:1: Error opening configuration file: /etc/openvpn/server.conf
2024-03-01T20:39:11.438894384Z Use --help for more information.
d3vilh commented 3 months ago

Hi @ohmex, Thanks for reporting! It is for some reason can't find your server.conf file. Could you share your docker-compose.yml configuration file please?

Thanks.

ohmex commented 3 months ago
version: "3.5"
services:
    openvpn:
       container_name: openvpn
       image: d3vilh/openvpn-server:latest
       privileged: true
       ports: 
          - "1194:1194/udp"
          - "2080:2080/tcp"
       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
       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=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
d3vilh commented 3 months ago

OK, I see the problem:

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 cap_add:

You need to update volumes with server.conf and recreate container.

       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
           - ./checkpsw.sh:/opt/app/checkpsw.sh
           - ./server.conf:/etc/openvpn/server.conf
        cap_add:
d3vilh commented 1 month ago

Has been fixed same way as issue #9