IP Firewall

You can use this document to learn how to implement an IP firewall rule. 

In the following example, the route is: *

This script will apply the firewall to your entire site. If you want to block a specific part of your site, then you can change the route to be more specific.

addEventListener('fetch', event => {
 event.respondWith(fetchAndApply(event.request))
})

async function fetchAndApply(request) { 
  //Create an Array of IP's to block
  var blacklist = ["192.168.1.1", "192.168.1.2"];
  //Check if IP is blacklisted by getting the client IP from the x-sp-client-ip header
  if (blacklist.includes(request.headers.get('x-sp-client-ip'))) {
    return new Response('Sorry, this page is not available.',
    { status: 403, statusText: 'Forbidden' })
 }
 
 return fetch(request)
}

You can access your script with any of the delivery domains on your account. 

Based on the above example, you can access the script with: https://domain.com/hello-world