通过另一台服务器中继PostgreSQL连接 [英] Relay PostgreSQL connection over another server

查看:126
本文介绍了通过另一台服务器中继PostgreSQL连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在具有严格限制的防火墙的远程服务器上使用PostgreSQL数据库,该防火墙仅允许来自我们的网络服务器的连接。这使在我自己的工作站上开发东西变得非常困难,因为我无法直接连接到该服务器来测试我的代码。

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?

推荐答案

使用ssh并创建本地隧道,类似这样(仅当您在Web服务器上运行ssh守护程序时有效)

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

以上内容将监听localhost上的5432(postgres端口),并将所有流量通过Web服务器转发到远程计算机。

The above will listen on 5432 (postgres port) on localhost and forward all traffic to remote machine via the web server.

如下面Ricky Han所述,您需要将地址192.168.1.128更改为PostgreSQL服务器的地址。

As mentioned below by Ricky Han, you need to change the address 192.168.1.128 to that of your PostgreSQL server.

显然,您将还需要更改webserver.com的名称! :-)

Obviously you will need to change the name of webserver.com as well! :-)

这篇关于通过另一台服务器中继PostgreSQL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆