Home Lab: OpenVPN Access Server
By Xin Lu profile image Xin Lu
2 min read

Home Lab: OpenVPN Access Server

Launch your OpenVPN Access Server instantly with this ready-to-use Docker Compose file. Skip the complex setup - just copy, paste, and get a fully functional VPN server with local network access.

Here's a ready-to-use Docker Compose configuration file for setting up OpenVPN Access Server. Make sure Docker Engine and Docker Compose Plugin (v2.0 or higher) are installed as per the official document.

services:
  openvpn-as:
    image: openvpn/openvpn-as
    container_name: OpenVPN
    cap_add:
      - NET_ADMIN
    ports:
      - "943:943"
      #- "443:443" # uncomment this line if you want to use TCP 
      - "1193:1193/udp"
    volumes:
      - openvpn-data:/openvpn
    restart: unless-stopped

volumes:
  openvpn-data:

Edit and Save: Open your docker-compose.yml file, paste in the configuration, save, and exit.

  • Start OpenVPN Access Server: Once the server is running, go to https://your-local-ip:943/admin/ to complete setup, including creating users and downloading connection files. If this URL doesn’t work, try using http instead of https.
    • Default admin login and password is openvpn/openvpn
    • For regular user login, use https://your-local-ip:943 without the /admin part
    • It's recommended to use a reverse proxy, like Caddy or Nginx, to securely expose your OpenVPN Access Server to the internet
    • To allow VPN users access to your local network, follow these steps:
      • Go to Configuration -> VPN Settings -> Routing.
      • Select Yes, using NAT.
      • In the input box on the right, enter your local subnet in CIDR notation, such as: 192.168.0.0/24

Below is a breakdown of the docker-compose.yml file explained by ChatGPT:

  • cap_add: NET_ADMIN: Grants the container network administration capabilities, necessary for managing VPN connections and network settings, which are central to OpenVPN’s functionality.
  • ports:
    • 943:943: Maps the web admin and user interface for OpenVPN Access Server to port 943 on the host machine. This allows access to the admin UI at https://your-local-ip:943/admin.
    • 1193:1193/udp: Maps the default UDP port (1193) used by OpenVPN for client connections. UDP is the recommended protocol for VPNs due to its speed and reliability.
    • Optional 443:443 (commented): This line, if uncommented, allows connections over TCP on port 443, which can be useful if UDP connections are restricted on a network.
  • volumes:
    • openvpn-data:/openvpn: Stores OpenVPN configuration and user data in a persistent Docker volume (openvpn-data). This ensures that all data remains intact even if the container restarts, preserving configurations, certificates, and user accounts.
By Xin Lu profile image Xin Lu
Updated on
Docker HomeLab