Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Postgres Servers #243

Open
maxbec opened this issue Sep 3, 2024 · 4 comments
Open

Multiple Postgres Servers #243

maxbec opened this issue Sep 3, 2024 · 4 comments

Comments

@maxbec
Copy link

maxbec commented Sep 3, 2024

Hey guys,

how can i serve multiple postgres DBs with Caddy as reverse proxy? Cant get it to work with the opnsense plugin.
Example:
db1.example.com => local:8446
db2.example.com => local:8447

Any ideas?

@coolaj86
Copy link

You'll need to upgrade psql to Postgres 17 and use sslnegotiation=direct. Search other issues here for some recipes for how to do it with earlier versions, or tls sni alpn routing in general.

@divyam234
Copy link

divyam234 commented Oct 19, 2024

@coolaj86 tried this flag but getting this error below

"level":"error","ts":1729340050.662618,"logger":"caddy.listeners.layer4","msg":"handling connection","error":"tls: client requested unsupported application protocols ([postgresql])"}

connecting with ?sslnegotiation=direct&sslmode=require

@coolaj86
Copy link

coolaj86 commented Oct 19, 2024

You need to set the ALPN matcher in caddy l4 to include postgresql.

Alternatively, you can temporarily disable ALPN in psql (I think the option will show up in --help).

@divyam234
Copy link

divyam234 commented Oct 19, 2024

Working config for postgres 17

{
    servers {
        listener_wrappers {
            layer4 {
                @postgres tls sni example.com
                route @postgres {
                    tls {
                      connection_policy {
                        alpn postgresql
                      }
                    }
                    proxy postgres:5432
                }
            }
            tls
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants