我正在尝试遵循数字海洋教程,以服务器模式配置pgadmin4,但该死的时间太长了,我必须先配置apache服务器,python和virtualenv(通过其他2个教程)。
我不想仅通过pgamin 4访问postgres在服务器中安装太多依赖项。
你们是怎么做到的?
我正在通过https运行Go Web服务器,监听端口443并将80重定向到443
答案 0 :(得分:1)
Seeing your other answer I would like to offer a more secure alternative.
What's wrong with the current approach?
Your PostgreSQL instance is accessible from the internet. Generally you should try to limit access only where it is required. Especially if you are not using SSL to connect to PostgreSQL, an open port like this is a target for traffic interception and brute force attacks.
Alternative
Seeing that you are you using JetBrains IDE's you only need one other step to access your data - setting up a SSH tunnel.
This encrypts with SSH all your connections between development host and server without exposing PostgreSQL to the outside world.
In the connection settings for your database in the Jetbrains IDE select the SSH/SSL tab and "Use SSH tunnel". Input the information of your server and the SSH user + password/SSH key (use SSH keys for better security) into the relevant input fields.
Undo the settings changes you did to open the firewall and configure PostgreSQL to listen to all nodes.
Connections to your database are now possible over encrypted tunnels without exposing your database to any unwanted attacks.
答案 1 :(得分:0)
这就是我通过webstorm实现从笔记本电脑到ubuntu VPS的连接的方法(我想任何intellij的作品也应该可以与其他IDE一起使用)
0登录到您的服务器
1.通常在postgresql.conf
下找到/etc/postgresql/10/main
2. sudo nano postgresql.conf
3.找到并更改连接处的线
listen_addresses = '*'
然后在同一目录中编辑:sudo nano pg_hba.conf
#TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
Md5表示我连接了用户及其密码
5不要忘记允许ufw(防火墙)
sudo ufw allow 5432/tcp
打开webstorm>数据库(选项卡)>单击+添加PostgtresSQL源(填写相关信息,用户名,密码,数据库名,主机和端口等)
jdbc:postgresql://example.com:5432/my_database_name
按下模式并同步,或者按下:
Source > Settings > Schemas tab > [check] All Databases > refresh