Hi. I have recently setup OpenWrt 22.03 with OpenVPN and it works great. I'm using policy-based routing to only use the VPN for requests to certain domains - all good. What I want to do is to shut down the VPN tunnel after an inactivity timeout and then auto-reconnect when a request is made of one of the target domains. I'd like the request to just wait until the tunnel is reconnected (or alternatively drop). I never want those requests to go through my default gateway when the VPN is down. In the OpenVPN config file I can specify an "inactive" timeout which drops the connection after a specified number of seconds. But the tunnel remains "up" - at least in the LuCI interface - even though it doesn't work. It's the auto-reconnect I can't figure out how to do. Any advice?
This traffic is all HTTPS, btw. Makes me think of setting up nginx to intercept, then get a chance to run a script to make sure the tunnel is up, then forward the request on that interface, maybe. Not sure if that's the most elegant solution.