使用从运行Postgres的类似服务器借用的设置9.4.1 & pgbouncer 1.6.1,我有多个用户通过端口6543上的pgbouncer连接到数据库。我也有第二个运行PostgreSQL 9.4.5的服务器,我已验证所有用户只能使用设置为verify-full
的TLS/SSL直接连接到数据库(在端口5432上)。pgbouncer 1.7使用TLS/SSL客户端和服务器连接
但是,我需要创建一个组合这些配置的环境:其中所有用户都通过TLS/SSL通过pgbouncer连接池连接到数据库。这意味着我需要在最近发布的(截至2015年12月18日)pgbouncer 1.7中使用新的TLS/SSL功能,但除了文档the new TLS parameters之外,我还没有发现任何可用的示例来演示新功能,也没有取得任何成功我自己通过pgbouncer在我的第二台服务器上使用TLS/SSL建立有效的连接。
我已经从我的第二台服务器中包含了来自postgresql.conf
,pg_hba.conf
,& pgbouncer.ini
的相关摘录。
的postgresql.conf:
ssl = on # (change requires restart)
ssl_cert_file = 'server.crt' # (change requires restart)
ssl_key_file = 'server.key' # (change requires restart)
ssl_ca_file = 'root.crt' # (change requires restart)
的pg_hba.conf:
hostssl all all 10.10.5.0/24 cert
pgbouncer.ini:
;
; pgbouncer configuration
;
[databases]
mydatabase = host=localhost port=5432 dbname=mydatabase
;
[pgbouncer]
listen_port = 6543
listen_addr = *
admin_users = lalligood, postgres
logfile = /tmp/pgbouncer.log
pidfile = /tmp/pgbouncer.pid
ignore_startup_parameters = application_name
server_reset_query = DISCARD ALL;
pool_mode = session
max_client_conn = 1000
default_pool_size = 300
log_pooler_errors = 0
; Improve compatibility with Java/JDBC connections
ignore_startup_parameters = extra_float_digits
; USER AUTHENTICATION (old way commented out with new lines below)
;auth_type = md5
;auth_file = pgbouncer/users.txt
auth_type = hba
auth_hba_file = pg_hba.conf
; TLS SETTINGS (NEW STUFF!)
client_tls_sslmode = verify-full
client_tls_key_file = server.key
client_tls_cert_file = server.crt
client_tls_ca_file = root.crt
server_tls_sslmode = verify-full
server_tls_key_file = /tmp/pgb_user.key
server_tls_cert_file = /tmp/pgb_user.crt
server_tls_ca_file = root.crt
pgbouncer开始,但是,当我尝试连接的用户“ lalligood',我得到以下错误:
ERROR: no such user: lalligood
pgbouncer.log包含每个尝试以下行:
2016-01-13 16:00:36.971 2144 LOG C-0xcad410:
(nodb)/(nouser)@10.10.5.194:54848 closing because: No such user:
lalligood (age=0)
如果必要的话,我可以提供更多的信息。如果任何人有任何意见/建议,我可能会忽略这个工作,我非常感谢帮助!