Freesoul
Freesoul

Reputation: 388

Block all except whitelisted IPs

I would like to block all access to our demo site for some time with the exception of a group of listed IPs & IP ranges. Could you advise on how to do this?

I am hosting on digital ocean and I have cloudflare activated.

Thanks for the help anyways

Upvotes: 2

Views: 791

Answers (1)

Paolo Tagliaferri
Paolo Tagliaferri

Reputation: 1021

This should be straightforward to achieve:

  1. Ensure that the DNS record for your demo site is proxied by Cloudflare. You can check this in the Cloudflare Dashboard for your domain, in the DNS tab.
  2. Add a Firewall Rule that will block all the traffic for your demo site unless it is coming from a list of allowed IP addresses. For example, using an expression such as:
(not ip.src in {192.0.2.1 192.0.2.2 192.0.2.3} and http.host eq "demo.example.com")

You can also define an IP List and reference to it in your Firewall rule - this would make it easier to maintain the list over time in a single place.

You can then turn the rule ON and OFF when needed.

Upvotes: 1

Related Questions