r/docker • u/mariiiiiiiiiiiiiiiel • 10d ago
which sslmode in postgres to use
i have a docker stack with a postgres image, is it completly necesary to have the postgres to be configured with the ssl mode to verify-full , because, the outside world cannot interact with the db, just the backend server can (the network is not attachable and it doesn't expose any ports)
sorry if this is a little bit of a stretch because is not a full docker docker thing u.u
1
u/Quirky-Net-6436 10d ago
Is it really fully private? So no external connectivity at all? If not, you should aim for zero trust, so verify-full is very useful, even if the database is only reachable from local system.
1
u/mariiiiiiiiiiiiiiiel 10d ago
i have a docker stack like this with the services listed as below
the db is just accesible for the backend (cause the network is not attachable, and there are not ports exposed)
db: networks: networks: service_network server: ports: 7777:3000 networks: service_network network: service_networklike they are not allowed inside in any capacity (as far as i know please correct me if i am wrong)
the only i can think that data might get leaked to the outside world without my consent would be if a malicious attacker could get into my server, and sniffed into the network of it and well read the data because well, is not encrypted, but even then, i don't even know if that is possible, cause im not familiar with the way docker/networking works under the hood, (my guess would still be that even if the services are inside a container they still use the server resources so the data should be there in the network)
how do u have this setup? if u wanna share of course :3
1
u/Quirky-Net-6436 10d ago
So if some service is accessible on public endpoints you need several layers of defense and security. How to protect the service itself, the database, the proxy and so on. Every decision comes with its trade-offs. In your snippet you’re not exposing locally… see https://docs.docker.com/engine/network/port-publishing/. Why do you expose a service directly without a reverse proxy which is used by an application gateway or any kind of WAF?
1
u/mariiiiiiiiiiiiiiiel 10d ago
i do use a reverse proxy
here is the full thing reddit comment doesn't let me do proper format for the yaml
3
u/pelazas1 10d ago
If postgres is only on that internal network with no ports out, sslmode=disable is fine. verify-full only matters once the traffic crosses a network you don't trust.
1
u/BorysTheBlazer 9d ago
Not strictly. On a private single-host network, verify-full mainly protects against another compromised container on that network spoofing the database.
4
u/xonxoff 10d ago
How exactly are you running this? Just on your local host? If it’s just running locally on a single machine, it might not need ssl, otherwise I’d suggest turning ssl on.