This repository contains a Docker Compose setup for deploying and managing an OpenVPN server with an admin panel and status page.
- OpenVPN server with both UDP and TCP support
- Client-to-client networking capability
- IPv6 forwarding support
- Administrative web panel
- Status monitoring page
- Persistent storage for configurations and certificates
- Automated health checks
- Docker and Docker Compose installed
- Basic understanding of networking and OpenVPN
- Port forwarding configured on your router/firewall (for external access)
-
Clone this repository:
git clone https://github.com/organicnz/openvpn.git cd openvpn
-
Start the services:
docker-compose up -d
-
Initialize the PKI (first time only):
docker-compose exec openvpn ovpn_genconfig -u udp://vpn.example.com docker-compose exec openvpn ovpn_initpki
-
Generate a client certificate:
docker-compose exec openvpn easyrsa build-client-full CLIENT_NAME nopass docker-compose exec openvpn ovpn_getclient CLIENT_NAME > CLIENT_NAME.ovpn
You can customize the deployment by setting these environment variables:
OPENVPN_ADMIN_USERNAME
: Username for the admin panel (default: admin)OPENVPN_ADMIN_PASSWORD
: Password for the admin panel (default: admin)
The OpenVPN server is configured with the following network:
- Server network: 10.20.0.0/24
- Docker internal network: 10.20.0.0/16
- OpenVPN Server: UDP port 1194, TCP port 1195
- Admin Panel: http://your-server-ip:8080
- Status Page: http://your-server-ip:8081
All OpenVPN configurations, certificates and keys are stored in the openvpn_data
Docker volume.
You can create a backup with:
docker run --rm -v openvpn_data:/data -v $(pwd):/backup alpine tar -czvf /backup/openvpn-backup.tar.gz /data
docker run --rm -v openvpn_data:/data -v $(pwd):/backup alpine sh -c "rm -rf /data/* && tar -xzvf /backup/openvpn-backup.tar.gz -C /"
If the container fails health checks, you can check logs with:
docker-compose logs openvpn
Common issues:
- Missing configuration file: Make sure to run the initialization steps
- Permission issues: Check file permissions in the mounted volumes
- Network conflicts: Ensure there are no conflicts with the 10.20.0.0/24 subnet
This project is open-source and available under the MIT License.