Question

Block all IP access to database droplet, except for one

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.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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