Hi,
Im woring in a strict environment and I have access to the postgresql machine only via http/https.
On this postgresql machine I would run 2 parallel environments with docker compose.
Is there a possibility to forward the http/https to the postgres container on 5432?
The other problem is , the postgres is in the non-external network. So is my scenario possible?
Traefik and target service should use the same Docker network, as Traefik Docker Configuration Discovery (with labels) is using the Docker network IPs.
You explicitly need to state the network when your target uses multiple networks and only one is shared with Traefik.
If your target service is not in a Docker network, then you need to set the service with loadbalancer.servers.url. This can’t be done with labels, but you need a separate dynamic config file, loaded via provider.file in static config.
My postgres service also in the docker network.
In my example above my docker compose has 2 networks.
Proxy-network - Traefik sitting in that
Private-network - Postgresql sitting in that with some other containers what not mentioned in my example.
So I want only expose the Postgresql:5432 from Private-network via the Traefik what is in the Proxy-network.
All of them in the docker-compose.
So the easy way is to add the proxy network also to my postgresql networks?
Yes, if you want Postgres to be reachable by Traefik, you need to add the proxy network, too. Then Postgres has 2 networks, you need to add docker.network in static or dynamic (labels) config for Traefik.
Do you know what you are doing? Does Postgres support TLS? Is your client set up to use TLS? Is your DB set up to use TLS? Will it create a custom certificate?
If you have not loaded custom TLS certs in Traefik using tls: true, Traefik will create custom certs which your client will probably not trust. For a trusted cert you would need paid certs, LetsEncrypt or import the custom certs on client side.
I would just remove that line and have a plain TCP/IP connection proxied from the client to your DB, without Traefik interfering with TLS. Let client and DB do the encryption, make sure it is enabled.
Note that you then need to use HostSNI(`*`), as Traefik can not look inside a TLS connection without having the cert available.
Hello,
Yes I know. I wont say I'm an expert but thatswhy Im here
Postgresql uses TLS.
I have a trusted ,payed certificate what im using in Traefik.
So this should not be the problem.
HostSNI(*) is not an option because I would use multiple postgresql on the machine behind traefik connected to different domain names.
I don’t know how Postgres handles TLS. You can try to use your paid certs with Postgres, too, and use tls.passthrough=true. Or let Postgres create its own proprietary cert and use insecureSkipVerify: true on global or service level.