Filter by HTTP Method

Filter by HTTP Method

You can filter out requests based on an HTTP method. For example, to perform a health check, you may want to filter out requests that use theHEAD HTTP method.

TO define an HTTP method by which to filter out requests:

  1. Open thePX_CUSTOM.vcl file.
  2. Add the required HTTP method as a regex expression using req.request.

EXAMPLE

sub px_custom_filter_by_http_method {
if ((req.request ~ "(?i)(HEAD)$") {
   set req.http.X-PX-filter-by:method = "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_http_method_enabled value to "true" (enabled). The default is "false" (disabled).
table px_configs {
  "px_filter_by_http_method_enabled": "true",
}

📘

Test

  1. Send a request that includes one of the defined HTTP methods.
  2. Open the console and search for your request. If you can't find the request, the feature is configured correctly.