Relay PostgreSQL connection over another server

江枫思渺然 提交于 2020-04-07 14:28:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!