VPN tunnel for apps
-
@Lonk Thanks! It might be easier for me to test with the package source. On Cloudron, you will need the manifest file to install and not just the docker image anyway.
I am happy to look into the Cloudron side of things whenever the package is semi-ready. Thanks for all the work!
-
@girish My DockerHub link you can pull to Cloudron and install comes with the Cloudron manifest So, rn, it’s working perfectly as an app in Cloudron now, fully operational (just doesn’t have a web interface to change the OVPN file yet but contains everything you need to test it, directly connects to my homes VPN until I revoke the cert which I didn’t want to do until you were done testing). I’ll post the source on GitLab today minus the hardcoded
.ovpn
file. But can I send you that specific file personally so you can use it for testing. You just place it in the/app/data
folder and restart the OpenVPN Client app and your IP for that container will magically change. So you can then test connecting another app to it network-wise (a la a cloudron eqivalent todocker run
's--net=container:vpn-client
runtime argument) and thencurl icanhazip.com
the “connected-to-the-vpn-client” app to see if it gets the same IP address as the OpenVPN Client Cloudron app.Does all of that make sense?
-
@girish I removed the pre-configured
.ovpn
file that is in the DockerHub version of 0.3 and added the full source code to Github. I tried adding it to Cloudron's Gitlab but it didn't let me create a repository for some reason so I just used Github.https://github.com/lonkle/openvpn-client-cloudron
If you need my preconfigured
.ovpn
file for testing instead of creating your own (you can add your converted.ovpn
file and rename it tovpn.conf
to the root directory before you install or after the install with the Cloudron File Manager, but if you do that you have to restart the app for it to take effect), then let me know so I can send it to you privately. I'll revoke my pre-configured one when you're done testing if you want to go that route (pun intended ). -
Goals for v0.5.0:
• Add an HTTP API endpoint to change and convert any
.ovpn
file a user supplies viaPOST
into the container and disconnect from current to connect to the newly added.ovpn
Goals for v1.0.0 (I'd consider it ready to upload to the official Cloudron Appstore at this point):
• Add a full web interface at the base URL of the app which uses the API endpoint in v0.5 to allow a user to submit any
.ovpn
file and convert it to what Cloudron needs to straight from a web interface (so they don't have to use the API or manually add it in the terminal / file manager, which would be confusing to new users using Cloudron).@girish Neither of these final features will be needed for you to do your testing whenever you'd like to connect one or multiple containers networks to the the "OpenVPN Client v0.3" app's network. So let me know a good way to send you my preconfigured
vpn.conf
file for you to use to test the feature. In the end, the API backend will automatically convert any.ovpn
files supplied by a user via the API or web interface into a format Cloudron needs; mine is just pre-configured for ya so you don't have to make your own just to test networking between the containers. -
@p44 I built the OpenVPN Client you can use to change your IP for your app. @girish offered to add a custom feature to Cloudron specifically to allow Cloudron apps to
network connect
to my OpenVPN Client app. So, not much longer now! I might try to dive into the network code myself but I'll admit, Cloudron's base code intimidates me. -
@mehdi Alright alright, you've convinced me - Is the flow similar to app creation to build it locally? Won't I need another license to start working on Cloudron locally though? So, the cloud can stay up, and I can develop this multiple app network VPN connection code locally? Normally, I could just use the free license for local dev, but I literally need three apps to test this because coincidentally this modification needs a total of 3 simultaneously running apps to test, the Open VPN Client App, another app to connect to it's network (so one to one connection is tested and confirmed), and then another app to simultaneously (3 apps needed to be installed at once to test) connect to the same Open VPN Client App's network.
I also just read on Gitlap that some of Cloudron is closed source, hmm, I should focus my feature requests on the closed source aspects I literally can't change myself and then merge request it.
-
@girish said in VPN tunnel for apps:
Step 2 is to then have some configuration to let apps use this container as the networking layer. If you ignore the UI/UX, this is really just a one-line change: https://git.cloudron.io/cloudron/box/-/blob/master/src/docker.js#L311 will be changed to the VPN client app's container. If we had a way to identify vpn clients, we can just have a dropdown of vpn clients as the available 'networks' in the app's configuration UI. And that should be it.
https://github.com/lonkle/openvpn-client-cloudron
I am finished with the MVP, it'll be ready for the App Store as soon as I include instructions on install to show the user installing it how to get their
.ovpn
in the/app/data
folder for the OpenVPN Client to pick it up and some other small polishes (like using a wildcard to pick up whatever.ovpn
file they put into/app/data
and adding the necessary one-liner automatically to the file for it to be compatible with Cloudron's network. But, as of now, every time you change OVPN servers, you have to restart the app. I'm going to use the Cloudron API to do this manually but I haven't found a way to not restart the app yet and just disconnect + connect to a different server on-demand, just at initial runtime.Oh, and when you need an
.ovpn
for testing container network connections, let me know! But I'm gonna take a stab (no promises, nervous at how different the Cloudron base code is gonna be ) at getting this working myself on the Cloudron side. Thanks for pointing me in the right direction! -
Okay, I'm close to finalizing the Cloudron side of things. But I can't seem to find a function like
getContainerIdByAppId('com.joelstickney.openvpn-client')
@girish Do you know any functions off-hand or maybe some files that I should be lookin’ into? I need the Open VPN client's (sub)Container ID so I can apply it to the other (sub)Containers network(s).
-
I'm now able to connect any container to any network I want on app startup based on the app's FQDN or ID. But even if I create a separate network than
cloudron
and stick the OpenVPN Client in there with another app. The other app doesn't inherit the OpenVPN Client's IP like it does when you connect the connectors directly on thebridge
network using thedocker run --net
command.There may be a firewall issue though. Cloudron does have a very specific subnet and maybe I can't escape it without running into a firewall.
-
@girish No problem at all. I can work on porting some other apps in the meantime. Really love the platform you guys created.
And I might be able to figure the answer to my own question. I made an Ubuntu Graphical 18.04 Virtual Machine and installed Cloudron on that so I can develop for the “above subcontainer level” (AKA:
box
) app code. I am tho running into the two app restriction on localhost - I wish that limitation didn’t apply to custom apps developers are making.Anyway, thank you again for being as responsive as you have been and don’t mind me updating as I go. Respond whenever you think you can. ️ You guys have done some really amazing work; both of you are inspirations tbh.
-
@girish
Goals for v0.4.0:
• Modifydocker.js
to use thecontainer:vpnContainerID
NetworkMode for all apps choosing to run their traffic through the VPN (presumably a drop-down box in the config option of an app which will need to be coded in the dashboard, hardcoded to the ovpn-client's manifest ID). Note: Need to removehostname
and anyport bindings
so that the container takes on the attributes of the VPN otherwise the NetworkMode will conflict with the VPN Client's Network.Goals for v0.5.0:
• Add an HTTP API endpoint to change and convert any .ovpn file a user supplies via POST into the container and disconnect from current to connect to the newly added .ovpnGoals for v1.0.0 (I'd consider it ready to upload to the official Cloudron Appstore at this point):
• Add a full web interface at the base URL of the app which uses the API endpoint in v0.5 to allow a user to submit any .ovpn file and convert it to what Cloudron needs to straight from a web interface (so they don't have to use the API or manually add it in the terminal / file manager, which would be confusing to new users using Cloudron). -
@girish And I will post on each app's wishlist forum post when I start work on converting.
I'm just really stuck on this NetworkMode code. No matter what I do, the NetworkMode stays
cloudron
even after restarting the container and hardcoding it to use the NetworkModecontainer:vpncontainerid
. Effectively making the app useless. The NetworkMode needs to change, but it's like once the NetworkMode is attached to an app, it stays on there no matter what. Still experimenting as that's the last piece of this puzzles aside from finding a function that can take a cloudron-manifest-id and translate it to a Docker Container ID (so I don't have todocker network inspect
and then hardcode it's ID). -
@mehdi My OpenVPN Client doesn't require any more edits to work on Cloudron. Or are you referring to the "other container" that I'm trying to attach to my OpenVPN Client (to then change it's public IP which I just check with
curl icanhazip.com
every new experiment)? So all apps / cloudron containers I just restart from the Cloudron dashboard since they are the one's who'sNetworkMode
needs to becontainer:vpn-docker-constainer-id-or-name-but-really-just-id
(it's hard to parse containters and networks because docker.js has to sent the app names to their container ids to prevent container naming conflicts) - which is abox
problem that needs to be solved (particularlydocker.js
).I see a lot of mentions of
appContainer
references andsubcontainer
references in REing thedocker.js
code. But they're all just regular containers (nothing is special about them except a flag is set if it's.a subcontainer) so that must be a Cloudron nomenclature.I think (really just hope) I found my issue:
function containersCreate(req, res, next) { safe.set(req.body, 'HostConfig.NetworkMode', 'cloudron'); // overwrite the network the container lives in
Now why are you doing that to me @girish?