R
Railway•2mo ago
jimmy

Cloudflare Tunnel with Postgres DB

I have a cloudflared project which includes a Nextjs application and a Postgres DB. The nextjs application talks privately with the Postgres db through private networking. The tunnel is setup correctly for the nextjs application over http and it works fine. What i would like to achieve is to be able to connect to the postgres db from my local machine (whitelisting my ip address) without publicly exposing the db to the internet. So i tried to assign a Cloudflare Tunnel Public Hostname to Postgres (db.mydomain.com) and then make it accessible by certain IPs with Cloudflare ACLs. I am definitely doing something wrong here: I have created a public hostname with tcp protocol and passed in the railway private networking url (see image). but unfortunately when i try to connect to the db from my local machine, the connection times out. PS: i have not setup any ACLs yet so i am just trying to successfully connect to the db first. I really hope someone can give me a hand on this one. Thanks in advance
No description
8 Replies
Percy
Percy•2mo ago
Project ID: N/A
jimmy
jimmy•2mo ago
N/A
RedStar
RedStar•2mo ago
I don't think it's a good idea to do something like that for the database In this way you are hosting it to the public the database Try using the env DATABASE_PRIVATE_URL and link it to the site, without making the database public Because for example in my postgres case, I use the private networking connection to connect the database to my bot
Dane
Dane•2mo ago
You need to leave out the railway.internal in the URL. Should be just postgres:5432 I would recommend installing cloudflare warp on your local machine, and putting db.basilico.studio behind cloudflare access.
jimmy
jimmy•2mo ago
@Dane thanks for the hint, unfortunately just using postgres:5432 in the public hostname configuration does not work. Also i don't see how Cloudflare WARP can help me out on this. All i need is just to access the db hosted on Railway without exposing it to the public, it seems i can't find a solution to this 😭
Brody
Brody•2mo ago
is this a usecase for a cloudflare tunnel? I feel like this is what tailscale is for
jimmy
jimmy•2mo ago
@Brody thanks very much i didnt know about tailscale! That is exactly what i need. Do you think cloudflare tunnels and tailscale play well together?
Brody
Brody•4w ago
I don't think they really have anything to do with one another tbh @jimmy - I wrote a guide on how to set-up tailscale - https://docs.railway.app/tutorials/set-up-a-tailscale-subnet-router
Want results from more Discord servers?
Add your server