PostgreSQL – How to Disable PostgreSQL Port for Out-Server Connection

dockernginxpostgresql

I installed on my dedicated server ubuntu 20.04, docker, and container with postgressql.
I have problem beacouse I want that ubuntu blocked all connection with postgressql, out-server from domain, ip server etc, which added to server.

At the moment I can connect with PostgreSQL:

  • via ssh
  • via server ip. ip.ip.ip:5432/…
  • via all domain which added to nginx like domain1.com:5432 etc.

I want disabled connection via server ip and all domain which added to nginx

Best Answer

@mxcdh If you want your postgres container to be accessible from other docker container you don't need to expose the port, just put both containers in same docker network.