One option is Cloudflare tunnels. I recently wrote a script for my Start9 node, but you could take from this and adapt it for your use case. There are other similar services that likely have api or their own daemons. I've also had people recommend TailScale to achieve a similar thing.
Discussion
Woops, would probably help to link it nostr:note1rnh3kw8kgz4uhnude2fjrtsje5hpv087l8q0n3w986q6gfgq6dsss09x08