[英]How to restrict database ports on a cloud host?
I want to set up a node.js/mongoDB app on Digital Ocean. 我想在Digital Ocean上设置一个node.js / mongoDB应用程序。 It's not going to see a ton of traffic, so just one virtual machine instance is plenty.
不会看到大量流量,因此仅一个虚拟机实例就足够了。
When mongodb starts up, it attaches to default port 27017. Does this mean that the port is also available to anyone who hits myip:27017 or myserver.com:27017? mongodb启动时,它会连接到默认端口27017。这是否意味着该端口也可用于任何命中myip:27017或myserver.com:27017的用户?
How do I make the database only accessible to my app? 如何使数据库只能由我的应用访问?
Assuming no advanced/customized firewall settings: 假设没有高级/自定义防火墙设置:
If Mongodb is bound to 127.0.0.1 it will only be accessible from that machine or the local network. 如果Mongodb绑定到127.0.0.1,则只能从该计算机或本地网络进行访问。
If it is bound to 0.0.0.0 or an actual network interface connected to your server, it will be on the open internet. 如果绑定到0.0.0.0或连接到服务器的实际网络接口,它将在开放的Internet上。
Default config of mongodb installation on Ubuntu would bind 27017 to 127.0.0.1. 在Ubuntu上安装mongodb的默认配置会将27017绑定到127.0.0.1。
This means only 127.0.0.1 can access the port. 这意味着只有127.0.0.1可以访问该端口。
Check mongodb.conf
, and see if bind_ip = 127.0.0.1
exists. 检查
mongodb.conf
,看看是否存在bind_ip = 127.0.0.1
。
If there is not, anyone who can access your machine can access your mongodb. 如果没有,则可以访问您的计算机的任何人都可以访问您的mongodb。 It's dangerous.
这很危险。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.