OpenVPN server with an API for user management. Using this amazing project https://github.com/kylemanna/docker-openvpn
Using the docker-openvpn is simple and fun, but with time I wanted to automate my user management process and link it to other systems. The goal of this project is creating a basic configuration for docker-openvpn and an web API to manage the users.
- Clone the project and cd into it
- Execute
make build
to build the docker images - Edit the .env file and adapt the security related variables to your environment with save values
- SERVICE_USER
- SERVICE_PASSWORD
- Export the customization variables to your environment
- SERVER_ADDRESS
- CA
- Customize your server with these extra variables (optional)
- PROTOCOL (default:udp)
- VPN_PORT (default:1194)
- SERVER_SUBNET (default:192.168.253.0/24)
- DNS_SERVER (default:1.1.1.1)
- CLIENT_TO_CLIENT (default:no) Set this to yes if you want the clients to communicate amongst themselves.
- COMPRESSION (default:yes)
- Execute
make configure
to generate the base OpenVPN configuration - Execute
make run
to start the services - Open ports 5000/tcp and 1194/udp in your firewall
curl -u SERVICE_USER:SERVICE_PASSWORD SERVER_ADDRESS:5000
output: a list of certificates
curl -X POST -u SERVICE_USER:SERVICE_PASSWORD SERVER_ADDRESS:5000 -d '{"user":"username"}'
output: a text configuration for openvpn
curl -X POST -u SERVICE_USER:SERVICE_PASSWORD SERVER_ADDRESS:5000 -d '{"user":"username", "ip":"192.168.253.5"}'
output: a text configuration for openvpn
note: duplicates for ip address are not being handled. Use this at your own risk.
curl -X POST -u SERVICE_USER:SERVICE_PASSWORD SERVER_ADDRESS:5000 -d '{"user":"username", "duration":"5"}'
output: a text configuration for openvpn
curl -u SERVICE_USER:SERVICE_PASSWORD SERVER_ADDRESS:5000/username
output: a text configuration for openvpn
curl -X DELETE -u SERVICE_USER:SERVICE_PASSWORD SERVER_ADDRESS:5000/username
output: ok
curl -u SERVICE_USER:SERVICE_PASSWORD SERVER_ADDRESS:5000/status
output: an openvpn status log