Filter by User Agent
Warning
User agents can easily be spoofed by attackers. To prevent potential attacks, we recommend not to filter out traffic using user agents.
If you'd still like to run a test based on a specific user agent, disable this feature after the test.Â
TO define a user agent you want to filter out:
- Open the PX_CUSTOM.vcl fie.
- Add the required IP as a regex expression using req.http.User-Agent.
EXAMPLE
sub px_custom_filter_by_user_agent {
if (req.http.User-Agent ~ {"<User_agents_to_filter>"}) {
set req.http.X-PX-filter-by:ua = "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_user_agent_enabled value to "true" (enabled). The default is "false" (disabled).
table px_configs {
"px_filter_by_user_agent_enabled": "true",
}
Test
- Send a request that includes the filtered user agent.
- Openthe console and search for your request. If you can't find the request, the feature is configured correctly.
Updated 12 days ago