pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: - <grandebuzon@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Java proxies connection to postgres
Date: Sun, 08 Aug 2010 22:04:33 +0800
Message-ID: <4C5EB971.7000403@postnewspapers.com.au> (raw)
In-Reply-To: <AANLkTimPbHhimxz48Yva7apqBaTFH=DvDww-3gb1pc2h@mail.gmail.com>
References: <AANLkTimPbHhimxz48Yva7apqBaTFH=DvDww-3gb1pc2h@mail.gmail.com>

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



view thread (17+ messages)  latest in thread

Message-ID: <4C5EB971.7000403@postnewspapers.com.au>
Permalink:  ../4C5EB971.7000403@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4C5EB971.7000403@postnewspapers.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: craig@postnewspapers.com.au, grandebuzon@gmail.com
  Subject: Re: Java proxies connection to postgres
  In-Reply-To: <4C5EB971.7000403@postnewspapers.com.au>
  References: <AANLkTimPbHhimxz48Yva7apqBaTFH=DvDww-3gb1pc2h@mail.gmail.com> <4C5EB971.7000403@postnewspapers.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox