I'm using a PostgreSQL database on a remote server with a very restrictive firewall that only allows connections from our webserver. This makes developing stuff on my own workstation pretty difficult, as I cannot connect to this server directly to test my code.
What I'd like to do is set up some sort of proxy on our webserver that simply sends all queries to the firewalled server. Then I can use our server from my workstation to test my code. Any ideas how to do this or other ways that solve my problem?
For an environment without an application server, PostgreSQL provides two implementations of DataSource which an application can use directly. One implementation performs connection pooling, while the other simply provides access to database connections through the DataSource interface without any pooling.
use ssh and create a local tunnel, something like this (only works if you have an ssh daemon running on web server)
ssh [email protected] -CNL localhost:5432:192.168.1.128:5432
The above will listen on 5432 (postgres port) on localhost and forward all traffic to remote machine via the web server.
As mentioned below by Ricky Han, you need to change the address 192.168.1.128 to that of your PostgreSQL server.
Obviously you will need to change the name of webserver.com as well! :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With