Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qAFuG-0000Pu-4d for pgsql-general@arkaria.postgresql.org; Fri, 16 Jun 2023 20:18:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qAFuE-000630-WC for pgsql-general@arkaria.postgresql.org; Fri, 16 Jun 2023 20:18:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qAFuE-00062q-Lb for pgsql-general@lists.postgresql.org; Fri, 16 Jun 2023 20:18:50 +0000 Received: from prater.isola.red ([89.58.62.163]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qAFuC-002sEQ-0F for pgsql-general@lists.postgresql.org; Fri, 16 Jun 2023 20:18:50 +0000 Received: from wm.joel-hatsch.net (unknown [172.29.0.3]) (Authenticated sender: michael@weiller.eu) by prater.isola.red (Postfix) with ESMTPSA id 379B4C0A49; Fri, 16 Jun 2023 22:18:46 +0200 (CEST) MIME-Version: 1.0 Date: Fri, 16 Jun 2023 20:18:46 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: "Brainmue" Message-ID: <89c1684486557d535c3062e44073b05e@weiller.eu> Subject: Re: Question: Multiple pg clusters on one server can be reached with the standard port. To: "Francisco Olarte" Cc: "Thomas Markus" , pgsql-general@lists.postgresql.org In-Reply-To: References: <71943c04e05c3c13d5cd2b287909f351@weiller.eu> <0c2dd853-08ec-dbed-00c3-a680ae711d89@proventis.net> <6c3babfef3065d8e1d69b8618a1aeac3@weiller.eu> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 16. Juni 2023 21:54, "Francisco Olarte" schrieb: > Michael: >=20 >=20On Fri, 16. Juni 2023 at 13:53, brainmue wrote: >=20 >>=20Because with iptables or netfilter I can't forward TCP packets based= on the DNS alias name. Or is >> that possible? >=20 >=20The dns alias name does not reach the listening tcp socket, it is > mapped to the target record, then finally to the A record and this is > what is used to start the tcp connection. >=20 >>=20I have the same problem with nginx. >=20 >=20In nginx you cannot use the dns alias, but if you are using http the > "normal" clients send it as host when they open an url. But there is > no "host" parameter in the pg protocol. There is a dbaname, which can > be used with the adequate software, like pgbouncer, but you said you > do not like it. >=20 >=20You may try to write a small program which parses the startup message > and redirects the connection based on the info there. I'm not sure why > pgbouncer has not this option, but it may be because it has a lot more > option. It does not seem to be that difficult, receive the packet, > parse it, connect to remote, send it the packet and from there on just > forward traffic blindly. Parsing startup seems quite simple, > maintaining a socket pool and forwarding is simple, you could probably > prototype that in an afternoon ( if no guru replies me "but this won't > work because .... ). >=20 >>=20I just looked in the documentation again but I can't find a way to d= istinguish which cluster to >> forward to based on the DNS alias. >=20 >=20As I asaid above, DNS alias is not avalilable to the listener. On any > protocol. Things like http work because the clients send the dns alias > on some place on the default usage, but you can write an http client > which sends Host: from the uri given but connects to a different IP > address. >=20 >=20Francisco Olarte. Thank you for the detailed explanations. I could not have explained it but it also seemed strange to me that it sh= ould go that way. pgbouncer I will definitely look again carefully. Maybe I already have my solution with it. Regards Michael