简体   繁体   English

如何限制云主机上的数据库端口?

[英]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.

相关问题 如何在节点 js 中限制对谷歌云平台上存储桶文件的访问 - How to restrict access to a file for a bucket on google cloud platform in node js 使用 Cloud Functions for Firebase 时如何将 CORS 限制为特定来源? - How to restrict CORS to a specific origin when using Cloud Functions for Firebase? 如何在多个端口上托管多个节点应用程序 - 在 package.json 中硬编码的端口 - how to host multiple node application on multiple ports - port hardcoded in package.json 如何在谷歌云上托管 node.js 应用程序? - How to host node.js app on google cloud propertly? 如何在Cloud9IDE中的Restify中配置自定义主机? - How to configure custom host in Restify in Cloud9IDE? 如何限制find()期间数据库中不存在的mongoose默认值 - How to restrict mongoose default value whose not present in database during find() 如何在Apache上配置端口? - How to configure ports on Apache? Dockerfile:如何转发端口? - Dockerfile: how to forward ports? 如何在云代码中查询Firebase实时数据库 - How to query firebase realtime database in cloud code 如何正确查询实时数据库以实现云功能? - How to query realtime database properly for cloud fucntion?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM