Filter by IP
  • 13 Nov 2023
  • Dark
    Light

Filter by IP

  • Dark
    Light

Article Summary

If you want to run internal tests from your office/site IP addresses, you can filter out requests originating from a specific IP address.

TO define an IP address you want to filter:

  1. Open the PX_CUSTOM.vcl fie.
  2. Add the required IP as a regex expression using req.http.Fastly-Client-IP.

EXAMPLE

sub px_custom_filter_by_ip {
   if (req.http.Fastly-Client-IP ~ {"<filterd_ip_address_regex>"}) {
      set req.http.X-PX-filter-by:ip = "1";
   }
}

To learn more about custom subroutines, see Customized subroutines.

TO enable the feature:

  1. Open the PX_CONFIG.vcl file.
  2. Set the px_filter_by_ip_enabled value to "true" (enabled). The default is "false" (disabled).
table px_configs {
  "px_filter_by_ip_enabled": "true",
}
TEST
  1. Send a request that includes the filtered IP.
  2. Openthe console and search for your request. If you can't find the request, the feature is configured correctly.




Was this article helpful?