问题
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?
回答1:
use ssh and create a local tunnel, something like this (only works if you have an ssh daemon running on web server)
ssh user@webserver.com -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! :-)
来源:https://stackoverflow.com/questions/15768913/relay-postgresql-connection-over-another-server