Skip site navigation (1) Skip section navigation (2)

Re: Java proxies connection to postgres

From: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: - <grandebuzon(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Java proxies connection to postgres
Date: 2010-08-08 17:32:58
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
You can use ssh to create a tunnel between your local host and the
remote host over the ssh connection.

ssh -L 5432:localhost:5432 user(at)db(dot)host

That will open port 5432 locally and any connections received by that
port will be forwarded to port 5432 on localhost as resolved from the
far side of the connection - so 'localhost' in that context is the
remote db server.  I create temporary proxies through firewalls via
ssh all the time and it works very nicely.  You can create a similar
proxy by ssh'ing out of the db server back to your workstation if you
cannot open a port for ssh on the db server and it isn't already
running sshd.    In that case, you use the -R parameter to specify the
remote port that will be forwarded back to the local port.

On Sun, Aug 8, 2010 at 7:04 AM, Craig Ringer
<craig(at)postnewspapers(dot)com(dot)au> wrote:
> 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".
> 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
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:

In response to

pgsql-jdbc by date

Next:From: John T. DowDate: 2010-08-09 00:55:19
Subject: Re: 9.0 Driver
Previous:From: Craig RingerDate: 2010-08-08 14:04:33
Subject: Re: Java proxies connection to postgres

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group