Block all IP access to database droplet, except for one

August 24, 2017 137 views
API Ubuntu

Hi, I have an droplet which is running a NGINX and I wish to block my another droplet running Mongo to be visible exclusively for the NGINX one. Could you help me? Both are running Ubuntu.

2 Answers

Using ufw, first you need to deny all traffic to your database port

sudo ufw deny 3306/tcp

then allow your IP to your server:

sudo ufw allow from Your.IP.Address to any port 3306 proto tcp
Have another answer? Share your knowledge.