Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relay PostgreSQL connection over another server

Tags:

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?

like image 530
Jochen Ritzel Avatar asked Apr 02 '13 16:04

Jochen Ritzel


People also ask

How does postgres connection pooling work?

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.


1 Answers

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! :-)

like image 192
DAB Avatar answered Oct 03 '22 05:10

DAB