HUB
Sign inSign up

mmtaee/ocserv-dashboard

By mmtaee

•Updated 17 days ago

Self-hosted OpenConnect VPN server with a modern web dashboard, user management, traffic monitoring.

Image
0

1.2K

mmtaee/ocserv-dashboard repository overview

⁠Ocserv Dashboard

A modern, self-hosted OpenConnect VPN server with a powerful web-based management dashboard.

Ocserv Dashboard provides an integrated environment for deploying and managing OpenConnect VPN Server (ocserv), including a Go backend, PostgreSQL database, nginx, administration dashboard, and customer portal.

⁠✨ Features

  • VPN user and group management
  • User expiration and traffic quotas
  • Active sessions and bandwidth monitoring
  • Real-time server statistics and activity logs
  • Role-based staff administration
  • Customer self-service portal
  • Optional Telegram bot integration
  • Multi-node master/agent architecture
  • Automatic database migrations
  • Multi-architecture Docker images (amd64 / arm64)

⁠🐳 Docker Installation

⁠1. Requirements
  • Linux server with Docker Engine and Docker Compose
  • /dev/net/tun support
  • NET_ADMIN capability
  • Access to the Docker socket for supported management features
  • Available TCP/UDP port 443 and TCP port 3000
  • Domain name or public IP address
  • Appropriate TLS configuration
⁠2. Pull the Docker Image
docker pull mmtaee/ocserv-dashboard:latest

For production, pin an available release tag instead of latest.

⁠3. Create the Project Directory
mkdir -p ocserv-dashboard
cd ocserv-dashboard
⁠4. Configure Environment Variables

Create a .env file:

nano .env

Add the following configuration:

# Server Configuration
HOST="vpn.example.com"
ETH="eth0"

# Security
SECRET_KEY="REPLACE_WITH_64_CHARACTER_RANDOM_HEX"
POSTGRES_PASSWORD="REPLACE_WITH_STRONG_DATABASE_PASSWORD"

# Administrator Account
SUPERADMIN_USERNAME="admin"
SUPERADMIN_PASSWORD="REPLACE_WITH_STRONG_ADMIN_PASSWORD"

# Node Configuration
AGENT_NODE=false

# VPN Configuration
OCSERV_PORT=443
OC_NET="172.16.24.0/24"
OCSERV_DNS="1.1.1.1"

# Dashboard
WEB_PORT=3000

# SSL Configuration
SSL_CN="vpn.example.com"
SSL_ORG="ocserv-dashboard"

# Optional Services
TELEGRAM_BOT_ENABLED=false
CUSTOMER_API_ENABLED=true

Important configuration notes:

VariableDescription
HOSTPublic domain name or IP address of the VPN server
ETHHost network interface used for VPN traffic
SECRET_KEY64-character random hexadecimal secret
POSTGRES_PASSWORDPassword for the PostgreSQL database
SUPERADMIN_USERNAMEInitial administrator username
SUPERADMIN_PASSWORDInitial administrator password
AGENT_NODEfalse for a full/master deployment
OCSERV_PORTVPN listening port, default 443
OC_NETVPN client address subnet
OCSERV_DNSDNS server assigned to VPN clients
WEB_PORTDashboard HTTPS port, default 3000
SSL_CNCertificate common name
SSL_ORGCertificate organization
TELEGRAM_BOT_ENABLEDEnable or disable Telegram bot integration
CUSTOMER_API_ENABLEDEnable or disable the customer portal

Generate a secure secret:

openssl rand -hex 32

Copy the generated value into SECRET_KEY.

Find your host network interface:

ip route get 1.1.1.1

Update ETH with the correct interface, then secure the environment file:

chmod 600 .env

Never commit .env to a public repository.

⁠5. Create Docker Compose Configuration

Create compose.yml:

services:
  ocserv:
    container_name: ocserv
    image: mmtaee/ocserv-dashboard:latest

    env_file:
      - .env

    environment:
      HOST_PROC: /host/proc
      HOST_SYS: /host/sys
      POSTGRES_HOST: 127.0.0.1
      TELEGRAM_RECEIPTS_DIR: /opt/ocserv_dashboard/uploads/receipts

    cap_add:
      - NET_ADMIN

    sysctls:
      net.ipv4.ip_forward: "1"

    devices:
      - /dev/net/tun:/dev/net/tun

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - ./data/ocserv:/etc/ocserv
      - ./data/postgresql18:/var/lib/postgresql
      - ./data/cron_journal:/app/cron_journal
      - ./data/telegram_receipts:/opt/ocserv_dashboard/uploads/receipts

    ports:
      - "${OCSERV_PORT:-443}:${OCSERV_PORT:-443}/tcp"
      - "${OCSERV_PORT:-443}:${OCSERV_PORT:-443}/udp"
      - "${WEB_PORT:-3000}:${WEB_PORT:-3000}"

    restart: unless-stopped

Important: Keep the container name ocserv. Application features that access ocserv logs through the Docker API depend on it.

PostgreSQL 18 data must be mounted at /var/lib/postgresql, not /var/lib/postgresql/data.

⁠6. Create Persistent Storage
mkdir -p \
  data/ocserv \
  data/postgresql18 \
  data/cron_journal \
  data/telegram_receipts

These directories preserve VPN configuration, database data, scheduled job state, and Telegram receipt uploads across container restarts.

⁠7. Start the Container
docker compose up -d

Check startup logs:

docker compose logs -f ocserv

Wait for initialization and database migrations to complete.

⁠8. Access the Dashboard

Open:

https://vpn.example.com:3000/

Log in using the SUPERADMIN_USERNAME and SUPERADMIN_PASSWORD values configured in .env.

The customer portal is available at:

https://vpn.example.com:3000/customer/

The customer portal is enabled when CUSTOMER_API_ENABLED=true and the published image includes the customer portal build.

⁠⚙️ Run Directly with Docker

If you prefer Docker CLI instead of Docker Compose, first create the .env file and persistent directories as described above.

docker run -d \
  --name ocserv \
  --env-file .env \
  -e HOST_PROC=/host/proc \
  -e HOST_SYS=/host/sys \
  -e POSTGRES_HOST=127.0.0.1 \
  -e TELEGRAM_RECEIPTS_DIR=/opt/ocserv_dashboard/uploads/receipts \
  --cap-add=NET_ADMIN \
  --sysctl net.ipv4.ip_forward=1 \
  --device /dev/net/tun:/dev/net/tun \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v /proc:/host/proc:ro \
  -v /sys:/host/sys:ro \
  -v "$PWD/data/ocserv:/etc/ocserv" \
  -v "$PWD/data/postgresql18:/var/lib/postgresql" \
  -v "$PWD/data/cron_journal:/app/cron_journal" \
  -v "$PWD/data/telegram_receipts:/opt/ocserv_dashboard/uploads/receipts" \
  -p 443:443/tcp \
  -p 443:443/udp \
  -p 3000:3000 \
  --restart unless-stopped \
  mmtaee/ocserv-dashboard:latest

This example assumes the default VPN and dashboard ports. Adjust the port mappings if you change them in .env.

View logs:

docker logs -f ocserv

⁠🔄 Updating

Pull the latest image:

docker compose pull

Recreate the container:

docker compose up -d

Check logs:

docker compose logs -f ocserv

Back up your persistent data before upgrading, especially PostgreSQL and ocserv configuration.

⁠🌐 Network Ports

PortProtocolPurpose
443TCPOpenConnect VPN
443UDPOpenConnect VPN
3000TCPAdmin dashboard and customer portal
8080TCPAgent API on agent deployments

The agent API should be restricted to trusted networks and should not be exposed publicly without appropriate protection.

⁠🔐 Security

  • Always generate a unique SECRET_KEY.
  • Use strong database and administrator passwords.
  • Protect .env with restricted file permissions.
  • Configure TLS correctly.
  • Back up persistent directories regularly.
  • Restrict dashboard and administrative access.
  • Be aware that mounting /var/run/docker.sock gives the container significant control over the Docker host.
  • Never expose PostgreSQL directly to the public internet.

⁠📦 Docker Image Tags

Images are published through GitHub Actions when version tags are pushed.

Examples:

docker pull mmtaee/ocserv-dashboard:latest
docker pull mmtaee/ocserv-dashboard:v5.0

Use an existing published tag. For production deployments, prefer a pinned release version.


Ocserv Dashboard — Simplifying OpenConnect VPN management.

Developed and maintained by mmtaee⁠.

Tag summary
Recent tags
Content type
Image
Digest
sha256:05eb59289…
Size
225.1 MB
Last updated
17 days ago
docker pull mmtaee/ocserv-dashboard:latest