Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4EF0A62DB8E for ; Sun, 8 Aug 2010 11:04:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 99925-06 for ; Sun, 8 Aug 2010 14:04:46 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.4.227.11]) by mail.postgresql.org (Postfix) with ESMTP id BCB56632BC8 for ; Sun, 8 Aug 2010 11:04:45 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id B25799F7E; Sun, 8 Aug 2010 22:04:41 +0800 (WST) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 7C725AF5B1; Sun, 8 Aug 2010 22:03:27 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id a6gxoEu2QIT2; Sun, 8 Aug 2010 22:03:21 +0800 (WST) Received: from [10.1.1.3] (124-169-225-224.dyn.iinet.net.au [124.169.225.224]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 2FFC5AED33; Sun, 8 Aug 2010 22:03:21 +0800 (WST) Message-ID: <4C5EB971.7000403@postnewspapers.com.au> Date: Sun, 08 Aug 2010 22:04:33 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: - CC: pgsql-jdbc@postgresql.org Subject: Re: Java proxies connection to postgres References: In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/23 X-Sequence-Number: 20826 On 08/08/10 17:24, - wrote: > Could someone help me or suggest a solution? I want to connect from a > computer that has firewall to other where the postgres server run. The > problem is that computer (client) has a firewall and I have not access to > configure it, or open ports, ping does not respond. The computer (server) > where PostgreSQL has open ports but I can not connect to it from another > because of firewall. I can only access the computer through proxy. > How I could with Java programming access remotely through proxy to postgres > forgetting firewall? > Java has a connection with proxies. But I dont now how put together with > postgres connection. What kind of proxy is it that you have access to? Do you mean a regular HTTP proxy server? A SOCKS4 or SOCKS5 proxy? Or something else? If you can connect via a SOCKS proxy you should be able to set up a socket to the PostgreSQL server via the socks proxy and use that with the JDBC driver. You can specify the SOCKS proxy to use using the system properties "socksProxyHost" and "socksProxyPort". http://download.oracle.com/javase/7/docs/technotes/guides/net/properties.html http://download-llnw.oracle.com/javase/6/docs/technotes/guides/net/proxies.html There are also ways to configure this at runtime via a custom SocketFactory if you can't change system properties. If you don't have a SOCKS proxy to work with, and your proxy is HTTP-only, you're in trouble. If the proxy supports SSL/TLS you might be able to use its CONNECT command to proxy traffic, but it's probably not going to be something you can do without writing a custom SocketFactory. I can't help but wonder if it'd be a good idea to be able to pass a custom SocketFactory to the JDBC driver, in much the same way you can pass an SSLSocketFactory with the "sslfactory" JDBC URL argument. That way, someone needing to do funky things like tunnel a JDBC connection via a HTTPs proxy could do so without having to patch the driver, just by handing it a suitable Socket instance when asked. -- Craig Ringer