1
Create a role for the gateway
In Supabase, open SQL Editor, start a new query, replace the
placeholder with a strong password, and run:This role can only read. To let agents write, see letting agents
write.
2
Copy the session pooler's connection string
Click Connect at the top of the project and choose Session pooler.
It works over IPv4 on every plan, which the direct connection doesn’t.
Copy the string; it looks like:The part after
postgres. is your project ref.3
Download Supabase's certificate
Open Project Settings, then Database, and under SSL
Configuration download the certificate. Save it as
supabase-ca.crt
where the gateway runs: in Docker, in /etc/midplane/tls on the server.
The commands for My own certificate mount that folder at the same
path. With Midplane URL, or an Automatic (Let’s Encrypt)
certificate, add -v /etc/midplane/tls:/etc/midplane/tls:ro after each
docker run.4
Give setup the connection string
Change the copied string in three places: the user becomes
midplane_gateway. followed by your project ref, the password becomes the
role’s, and the end gets the TLS settings:sslrootcert is the certificate’s path where the gateway runs:
/etc/midplane/tls/supabase-ca.crt in Docker, or the file’s full path on
your computer. Put the line after its MIDPLANE_DSN_…= in the env file,
or paste it when midplane setup asks for the connection string
(deploy the gateway).5
Check that it connects
Setup says
ok with the database and its number of tables. Once the
gateway runs, Test connection on the Gateways page shows your
database’s id with ok, such as shop ok, 3 ms, and the policy
editor lists your tables.If it doesn’t work
Tenant or user not found: the user lacks.and your project ref.SELF_SIGNED_CERT_IN_CHAIN:sslrootcertis missing or names the wrong file.- Tables are empty: row-level security is on and has no policy for
midplane_gateway. Add an RLS policy that lets the role read, orALTER ROLE midplane_gateway BYPASSRLS;to let Midplane’s policy be the boundary.