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:
- Open thePX_CUSTOM.vcl file.
- 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:
- Open the PX_CONFIG.vcl file.
- 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
- Send a request that includes one of the defined HTTP methods.
- Open the console and search for your request. If you can't find the request, the feature is configured correctly.
Updated 12 days ago