[英]How do I configure proxy_pass on NGINX for PostgreSQL?
I have a PostgreSQL server started at a remote machine on the port 15432 .我有一个 PostgreSQL 服务器在端口15432上的远程计算机上启动。 I want to configure NGINX to make the database available remotely by host db.domain.my and port 5432 .
我想配置 NGINX 以使数据库可以通过主机db.domain.my和端口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远程连接数据库时,出现错误:
$ 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.我还尝试在
listen 5432
后添加ssl字,但没有任何成功。
How do I configure NGINX correctly?如何正确配置 NGINX?
Maybe remove http://
because it is a TCP connection (not a HTTP connection) and add so_keepalive=on
to listen 5432;
也许删除
http://
因为它是 TCP 连接(不是 HTTP 连接)并添加so_keepalive=on
以listen 5432;
so the connection stays open.所以连接保持打开状态。
Maybe you have to use stream
instead of http
block: https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/ Maybe you have to use
stream
instead of http
block: https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.