A
A
Alexey2020-10-28 10:31:02
PostgreSQL
Alexey, 2020-10-28 10:31:02

How to connect to Postgres that does not have public access?

Good afternoon!

There are two servers on Ubuntu 18.04, the first one has a public IP and nginx, and the second one is a postgres database server and there is no remote access to it. You need to configure it so that you can connect to the database through the first server. It is advisable to do this through nginx, since the firewall settings and all sorts of iptables cannot be touched there.
I understand that this is a type of port forwarding or something like that, but so far I can’t make it work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2020-10-28
@Espritto

Solved using this rule in nginx

stream {
    upstream backend {
        server 192.168.1.50:6432;
    }

    server {
        listen 8099;
        proxy_pass backend;
    }
}

A
Armenian Radio, 2020-10-28
@gbg

ssh - make a tunnel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question