Question

I have a droplet setup with a DB Server running

Hello I would like to setup a firewall rule that would allow access only from some of my deployed apps. Unfortunately those rules don’t seem to be available. Any ideas how I can restrict access to a droplet to just my apps?

Raphael


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.

Hi @rapsli,

if you are using two Droplets they’ll both have static IP addresses. In your DB Droplet, you can use the firewall to restrict all access but from the IP address you require.

Let’s say you are using UFW.

  1. sudo ufw enable && sudo ufw default deny incoming

Then you can allow specific IPs with:

  1. sudo ufw allow from 192.168.1.10 to any

This will allow IP address 192.168.1.10 to any port on your firewall. You just need to change the IP address to your Droplet’s IP address.

Please note that once you run the first command all connections should be lost, so I would recommend doing it over the recovery console. Additionally, allow your IP address as well so that you can SSH at any time.

Lastly, before doing anything I’ll also recommend creating a Snapshot just in case something happens. You can read more about them here https://docs.digitalocean.com/products/images/snapshots/

Hey @rapsli,

Are you referring to the DigitalOcean App Platform? If this is the case, currently the App Platform does not offer static IP addresses that you could use for your external firewalls.

It looks like someone has had the same idea before and has posted it on our Product Ideas board. The best thing to do would be to head over and add your vote to it, as well as adding any additional information in the comments for exactly what you’d like to see implemented!

https://ideas.digitalocean.com/digitalocean/p/app-platform-static-ip

If you are not referring to the App Platform, then what you could do is to use the IP addresses of the Droplets that you’ve deployed your apps on and allow those IP addresses via your firewalls:

https://docs.digitalocean.com/products/networking/firewalls/how-to/manage-droplets/

Hope that helps!

- Bobby.