A Docker container with Flask API for managing OpenVPN connection. Provides endpoints to:
- Establish OpenVPN connection
- Terminate active connection
- Retrieve current connection status
- Docker
- Docker Compose
- OpenVPN configuration files
- Clone the repository to your preferred location
- Configure
docker-compose.yml
(seeexample-docker-compose.yml
for reference) - Use the API endpoints to manage VPN connection
Retrieves current connection status.
Parameters: None
Response:
{
"ip": "string | null",
"country": "string | null",
"connected": "boolean",
"config_name": "string | null",
"error": "string | null | undefined"
}
Establishes VPN connection using specified configuration.
Parameters:
configName
(string, required): OpenVPN configuration filename or URL
Response:
{
"ok": "boolean",
"error": "string | null | undefined"
}
Terminates active VPN connection.
Parameters: None
Response:
{
"ok": "boolean",
"error": "string | null | undefined"
}
Clone the repository and navigate to project directory.
- Modify
example-docker-compose.yml
:- Set correct path to your OpenVPN config directory
- Adjust port mappings if needed
- Place your OpenVPN configuration files in specified directory
Build the Docker image:
docker compose -f example-docker-compose.yml build
Start the container:
docker compose -f example-docker-compose.yml up -d
- Check mock container in browser:
http://localhost:5112
. - Verify VPN service container has matching IP:
curl http://localhost:5111/api/info
Establish VPN connection:
curl "http://localhost:5111/api/connect?configName=your-config.ovpn"
Verify new IP address:
curl http://localhost:5111/api/info
Terminate VPN connection:
curl http://localhost:5111/api/disconnect
If you specify ENV variable STARTAPP_OPENVPN_CONFIG_NAME
as a config name.
On startup container will try to connect to OpenVPN with this config.
- All API endpoints return JSON responses.
- Error fields will not be shown when operation succeeds
- The service runs on port 5111 by default (adjustable in compose file).