Firewall only allow domain not a static IP

i would like secure a droplet with the DO firewall to only allow https requests from a specific domain as its ip changes often so cant set a static ip

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.

Bobby Iliev
Site Moderator
Site Moderator badge
February 6, 2023

Hi there,

The DigitalOcean firewalls are layer 4 firewalls, meaning that you can only filter TCP and UDP traffic. To be able to filter based on the domain name, you could do that via your web server, for example if you are using Nginx, then you could create a catch all Nginx server block and block all of the traffic, eg:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 412;

Then you could have your standard Nginx server block for your domain name as normal.

Site Moderator
Site Moderator badge
February 6, 2023

Hi @edwardshark,

If the IP address changes it’s going to be a little harder. Having said that, what you can do is if you know the range of the said IP to allow the range. That way if the IP changes with another from that range, you’ll still have it allowed.

Is that something you would consider?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel