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:

  1. Open the PX_CUSTOM.vcl fie.
  2. 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:

  1. Open the PX_CONFIG.vcl file.
  2. 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

  1. Send a request that includes the filtered user agent.
  2. Openthe console and search for your request. If you can't find the request, the feature is configured correctly.