dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Postgres unencrypted

Open danverbs opened this issue 1 year ago • 18 comments

I've set up a postgres instance in one of my projects and set up for external access but when I connect to it using Postico, it says the connection is unencrypted? How do I ensure this is encrypted?

If I set my cloudflare DNS to 'DNS Only' I get this message but can connect, if I set it to 'Proxied' I can't connect at all - the SSL connection is set to 'Full'

danverbs avatar May 17 '24 13:05 danverbs

I will need to test this, because I've used pgadmin and dbeaber and 0 issues, probably it may need to adjust the database connection because it depends on the driver the tool are using

Siumauricio avatar May 18 '24 00:05 Siumauricio

@danverbs I test and it was working looks like using the domain as hostname is not working only with the ip of the vps

Siumauricio avatar May 18 '24 03:05 Siumauricio

Ok so don't use the url provided in Dokploy settings? Just the ip of the vps?

danverbs avatar May 18 '24 09:05 danverbs

Correct @danverbs, for now just use the IP when I have more time I will investigate about this, but for now is functional

Siumauricio avatar May 18 '24 09:05 Siumauricio

I will try this and let you know. Thanks 👍🏻

danverbs avatar May 18 '24 09:05 danverbs

I tried with just the IP and it still says 'The server doesn't support TLS' and is unencrypted. Could you share the steps you took to set this up?

danverbs avatar May 20 '24 06:05 danverbs

Hey @danverbs , I tested and it was working I share the configuration

  1. Create a postgres database (In my case only set the database name)
  2. Expose port, type 5432 and then save.
  3. copy the postgresql connection.

image

  1. go to Postico image
  2. type the postgresql connection but remember to remove the domain and set the ip of your vps image
  3. Click add server
  4. Select the database, click on test button it will appear some alert about TLS just accept it Screenshot 2024-05-20 at 1 10 00 AM
  5. Then click on test to check the connection is working image

Siumauricio avatar May 20 '24 07:05 Siumauricio

Thanks - I can connect as shown in your steps but Postico still says the connection is unencrypted? Surely we want it to be encrypted?

danverbs avatar May 20 '24 07:05 danverbs

The question is that it marks you that it is not a secure connection because we do not implement any configuration for the domain with that port, but making adjustments with some traefik configuration would be enough to achieve that result.

What I recommend in case you are afraid or something like that that the probability that it will happen is really low, is simply when you finish doing your tasks in the database remove the exposed port that way no one will be able to access the database from outside.

Siumauricio avatar May 20 '24 07:05 Siumauricio

Thanks - I can connect as shown in your steps but Postico still says the connection is unencrypted? Surely we want it to be encrypted?

I agree with you, that it should be encrypted or have an option to make it so. @Siumauricio could you provide a working example config for adding this in traefik? Or is there an option to add it to the creation workflow directly (checkbox or something)?

Apsysikal avatar Jun 14 '24 06:06 Apsysikal

You could add Traefik labels and put them under a subdomain like db.yourdomain.tld In this way, you'll have SSL for the subdomain - you'll connect on the port 80.

ciocan avatar Jul 07 '24 11:07 ciocan

Or we could follow railway's postgres template, where they issue their own certificate internally.

https://github.com/railwayapp-templates/postgres-ssl

PaiJi avatar Nov 08 '24 03:11 PaiJi

Hi @Siumauricio , I'm trying to connect my PostgreSQL database from cloudflare hyperdrive but it requires SSL/TLS connection. I used (create service -> database -> postgres) option from the ui to create the database. Now I can't find the dockerfile/compose file to modify the config to add traefik config which will allow SSL/TLS. So what should I do now?

Thanks Sakib

shakibhasan09 avatar Dec 20 '24 18:12 shakibhasan09

Yeah would be great if it could somehow define our own SSL certificate or one gets automatically added. Since it is required for a lot of things I do I dont have any databases on dokploy currently sadly.

Makisuo avatar Dec 21 '24 14:12 Makisuo

For info, Coolify is implementing this and I think it's a must-have

https://github.com/coollabsio/coolify/discussions/3976#discussioncomment-11934111

gurgunday avatar Jan 27 '25 18:01 gurgunday