Closed voboda closed 3 years ago
Found a way using an external cron orchestrator called deck-chores:
Added the deck-chores container to my docker-compose
officer:
container_name: officer
image: funkyfuture/deck-chores:1
restart: unless-stopped
environment:
TIMEZONE: Europe/London
volumes:
- /var/run/docker.sock:/var/run/docker.sock
And then added these labels to the openvpn container:
labels:
deck-chores.rotate-vpn.command: pkill -SIGHUP -x openvpn
deck-chores.rotate-vpn.interval: 4 minutes
Every 4 minutes, this restarts the openvpn process within the container but leaves the vpn container itself running. When the openvpn process restarts, it rereads the config file. Since remote-random is set to on, it then chooses a new random vpn from the list.
Connectivity is disrupted for a few seconds, but all the connections between the vpn container and its clients stay intact.
Hope this helps anyone trying to do the same.
I'd like to rotate VPN servers regularly. Any suggestions?
I tried using a client.conf with multiple remotes and remote-random set to choose a random remote on startup, then used pm2 on the host to pkill openvpn (and also restart the dependent containers so they reconnect) on an interval. But that's proving a bit unreliable. Is there a better way?
Thanks!