How do I configure proxy_pass on NGINX for PostgreSQL?

Viewed 2595

I have a PostgreSQL server started at a remote machine on the port 15432. I want to configure NGINX to make the database available remotely by host db.domain.my and port 5432. The configuration I tried is:

server {
    listen 5432;
    server_name db.domain.my;

    location / {
        proxy_pass http://127.0.0.1:15432/;
    }
}

When I try to connect the database remotely with psql I get the error:

$ psql -h db.domain.my -U myuser
psql: received invalid response to SSL negotiation: H

I also tried to add ssl word after listen 5432 without any success.

How do I configure NGINX correctly?

1 Answers
Related