Can I setup a cloudflared tunnel for a Database

I am looking to setup a tunnel to my database running on a Windows Server and permanently connect to it from Web apps running on different Ubuntu Servers. Is this possible? How would I connect the Web Servers to the DB tunnel? I have setup an ssh tunnel recently and that works fine but I don’t know how to connect from another Ubuntu server.

Yes you can do this two ways I believe (untested)

Method1 - Tunnel

On the database server you need to publish the tunnel with cloudflared backed by your database port e.g. cloudflared tunnel --hostname mssql.gibson.test --url tcp://localhost:1433

On the ubuntu servers you simply need to connect to the whatever to the subdomain you assigned above. I’m not sure how firewall rules related to this new arbitrary tcp tunnels support, you would want at least IP whitelisting.

Method2 - Route advertising

On your windows server create a new private subnet say 10.164.0.0/32 and bind your db to listen to that.
Publish that route with cloudflared route
On your Ubuntu server install cloudflared-warp ubuntu package (released a few days ago) and authenticate, and then you can see the 10.164 network so just connect to 10.164.0.1:1433 for example

2 Likes

Okay, this is some helpful information I can test. About method 2, I am currently using the Free Plann, will I be able to authenticate the cloudflared-warp client? I tried adding a location in Teams and it would only let me add my IP address and not the Web Server’s IP.

Yes, it should be fine upto 50 people for free. You dont need to add the webserver IP in Teams admin because that is not an office location. It’s quite confusing, but that IP for a location is largely irrelvant, it’s just used to identify DNS traffic sent to 1.1.1.1 that isn’t secure by WARP.

I just realized that you assumed I was using MsSql on Windows, which of course is correct. Nice :smile:

1 Like

I can’t find any docs on how to install Warp for Ubuntu (https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/download-warp), do you have a location?

Check Cloudflare’s package repository at https://pkg.cloudflare.com/

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.