Fastly VCL v12 configuration options

Each Enforcer has a set of configuration options that control the Enforcer’s functionality and features. While some are required, many of these are optional configurations that you can use to customize the Enforcer’s behavior. You can reference available configurations with this article. You define and update Fastly VCL Enforcer configuration in the PX_CONFIGS VCL file (table px_configs) and, for custom logic, in the PX_CUSTOM VCL file. Some Remote Configuration values also require entries in Fastly dictionaries such as px_private and px_enforcer_config_rdata.

While all Enforcers come with the same set of required configurations, the optional configurations available for each may differ. We recommend updating to the latest Enforcer version to ensure you have access to the latest features and configurations.

Quick reference

Feature nameKeyTypeDefaultDescription
Application IDpx_app_idString""HUMAN Application ID
Authentication tokenpx_auth_tokenString""HUMAN authentication token
Cookie secretpx_cookie_secretString""HUMAN cookie secret. For rotation, also set px_cookie_secret_old.
Backend domainpx_backend_urlStringsapi-<PX_APP_ID>.perimeterx.netDomain to which HUMAN requests are sent
S2S timeoutpx_s2s_timeoutInteger (ms)1000Risk API backend timeout. Set on the PX_API backend in PX_CONFIGS, not as a table key.

Required configurations

These configurations are necessary for the Enforcer’s basic functionality and features.

Basic functionality configurations

px_app_id
stringRequired

Your HUMAN Application ID in the form of PX12AB34CD. You can copy this value from the HUMAN Console in Platform Settings > Applications Overview. If you have multiple applications, make sure to copy the ID of the application you want the Enforcer on.

Example
1# PX_CONFIGS
2table px_configs {
3 "px_app_id": "<APP_ID>",
4 # ...
5}
px_auth_token
stringRequired

The application’s server token needed to authorize with HUMAN’s backend. You can copy this value from the HUMAN Console in Platform Settings > Applications Overview > Click the appropriate application > Server token tab.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_auth_token": "<AUTH_TOKEN>",
5 # ...
6}
stringRequired

The secret used to encrypt and decrypt the risk cookie sent from the HUMAN Sensor. You can copy this value from the HUMAN Console in Sightline Cyberfraud Defense > Traffic Policy Overview > Click the appropriate application > Click the key > Copy value.

If you need to rotate secrets, then adjust this configuration to be the new generated cookie secret, then add an additional field name, px_cookie_secret_old, that holds the previous cookie secret value.

1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_cookie_secret": "<COOKIE_SECRET>",
5 # ...
6}
px_backend_url
stringDefaults to sapi-<PX_APP_ID>.perimeterx.netRequired

Do not set this value unless directed by your HUMAN Solutions Engineer.

The base URL for the HUMAN SAPI (Risk API and related calls). If empty, the Enforcer uses the default host for your Application ID.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_backend_url": "sapi-<APP_ID>.perimeterx.net",
5 # ...
6}
px_s2s_timeout
integerDefaults to 1000Required

Adding this value in the px_configs table has no effect. Set connect_timeout, first_byte_timeout, and between_bytes_timeout on the PX_API backend in the PX_CONFIGS VCL file.

The total time in milliseconds that the Enforcer will wait for the Risk API request to return before timing out and passing the request.

Example
1# PX_CONFIGS
2backend PX_API {
3 # ...
4 .connect_timeout = 2000ms;
5 .first_byte_timeout = 2000ms;
6 .between_bytes_timeout = 2000ms;
7 # ...
8}

Basic feature configurations

px_logger_severity
"none" | "error" | "debug"Defaults to "error"Required

The severity at which the logger will output logs.

  • none: The logger will not generate any logs.
  • error: The logger will only generate logs on fatal errors.
  • debug: The logger will generate detailed logs for debugging purposes. Not recommended for production environments.

See px_logger_auth_token for a header-based alternative.

When set to error, logs are sent to the endpoint named by px_error_syslog_name. When set to debug, logs are sent to the endpoint named by px_debug_syslog_name.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_logger_severity": "debug",
5 # ...
6}
px_custom_client_ip_extraction
functionDefaults to Returns ""Required

By default, the Enforcer reports the value from the Fastly-Client-IP header. If that value is inaccurate, implement this subroutine to return the true client IP from a trusted custom header. Returning an empty string falls back to Fastly-Client-IP.

Example
1# PX_CUSTOM
2sub px_custom_client_ip_extraction STRING {
3 if (req.http.true-client-ip) {
4 return req.http.true-client-ip;
5 }
6 return "";
7}
px_module_enabled
booleanDefaults to trueRequired

Whether the Enforcer module is enabled.

  • true: Enable the module
  • false: Disable the module
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_module_enabled": "false",
5 # ...
6}
px_module_mode
"monitor" | "active_blocking"Defaults to monitorRequired

The Enforcer’s operation mode.

  • monitor: The Enforcer performs all functions without returning block responses. Useful for analyzing and adjusting Enforcer behavior without serving block pages to end users. If you have routes that must have enforcement at all times, see Enforced routes.
  • active_blocking: The Enforcer will return block responses as needed.
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_module_mode": "active_blocking",
5 # ...
6}

Optional configurations

These configurations aren’t required, but you can use them to further customize the Enforcer’s behavior.

Activity headers

px_custom_activity_headers
functionDefaults to Returns ""

Fastly VCL cannot automatically report all request headers on async activities. Return a string of additional headers to include. Each header must use the form ",{%22name%22: %22<header name>%22, %22value%22: " if(req.http.<header name>, "%22" json.escape(req.http.<header name>) "%22", "null") "}".

Be sure to include the leading comma (,).

Example
1# PX_CUSTOM
2sub px_custom_activity_headers STRING {
3 declare local var.ret STRING;
4 set var.ret =
5 ",{%22name%22: %22my-header%22, %22value%22: " if(req.http.my-header, "%22" json.escape(req.http.my-header) "%22", "null") "}"
6 ",{%22name%22: %22my-header-1%22, %22value%22: " if(req.http.my-header-1, "%22" json.escape(req.http.my-header-1) "%22", "null") "}";
7 return var.ret;
8}

Additional activity handler

px_additional_activity_handler_enabled
booleanDefaults to false

Whether to invoke the px_custom_additional_activity_handler subroutine.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_additional_activity_handler_enabled": "true",
5 # ...
6}
px_custom_additional_activity_handler
functionDefaults to Empty

A custom subroutine that runs after the Enforcer prepares the page_requested or block activity and before forwarding the request to the next step in the pipeline. A common use case is to set the score as a variable or header so the application can read it and apply its own logic. HUMAN metadata is available on req.http.px-ctx. This subroutine is called in vcl_recv.

Example
1# PX_CUSTOM
2sub px_custom_additional_activity_handler {
3 declare local var.score STRING;
4 set var.score = if(req.http.px-ctx:pass-reason, "0", "100");
5 log "syslog " req.service_id " CustomLoggingEndpoint :: Score: " var.score ", Data Enrichment: " req.http.px-ctx:data-enrichment;
6}

Advanced blocking response (ABR)

px_advanced_blocking_response_enabled
booleanDefaults to true

In specific cases such as XHR post requests, a full CAPTCHA page render might not be an option. In such cases, the Advanced Blocking Response (ABR) returns a JSON object containing all the information needed to render a customized CAPTCHA challenge implementation such as a popup modal, a section on the page, etc. This provides more flexibility and customizability in displaying the CAPTCHA challenge.

  • true: Enable ABR
  • false: Disable ABR
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_advanced_blocking_response_enabled": "false",
5 # ...
6}

Block oversized Risk requests

px_block_size_exceeded_15k_headers_size
booleanDefaults to false

Due to Fastly size limits, large Risk API requests may return HTTP 413. By default, the Enforcer fails open. When enabled, those requests are blocked instead.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_block_size_exceeded_15k_headers_size": "true",
5 # ...
6}

Block result header

px_add_block_result_header
booleanDefaults to false

Whether to include px-ctx:block-result with value "0" (pass) or "1" (block) on origin requests. Useful while testing in monitor mode.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_add_block_result_header": "true",
5 # ...
6}

Bypass monitor header

px_bypass_monitor_header
stringDefaults to x-px-block

Activates the full blocking flow to verify the flow works as expected if the specified header is present on the request with a value of 1. Often used to test the Enforcer block workflow during monitor mode, where the Enforcer usually collects data without blocking user requests, before switching to active_blocking. Requests with this header will go through the entire blocking workflow despite being in monitor mode.

To disable blocking behavior on the specified header, set the value to 0.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_bypass_monitor_header": "x-bypass-monitor-mode",
5 # ...
6}

CORS support

You can configure the Enforcer to support Cross-Origin Resource Sharing (CORS) requests. CORS is a mechanism that lets the server indicate if a request contains cross-origin resources by adding special HTTP headers to the request. These headers let the browser load these resources. Without them, the browser may block requests to these resources for security reasons instead.

In most cases, CORS employs a two-stage procedure with a preliminary “preflight” request followed by the actual request. The preflight request checks if the actual request will be responded to. To learn more about different request types, see these examples.

You must configure the Enforcer to address both simple requests (without preflight) and more complex ones (with preflight) to support CORS requests.

px_cors_support_enabled
booleanDefaults to false

Whether to enable CORS support.

  • true: Enable CORS support
  • false: Disable CORS support

After setting this configuration to true, the Enforcer:

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_cors_support_enabled": "true",
5 # ...
6}
px_cors_create_custom_block_response_headers_enabled
booleanDefaults to false

Whether to invoke px_custom_cors_set_custom_block_response_headers.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_cors_create_custom_block_response_headers_enabled": "true",
5 # ...
6}
px_custom_cors_set_custom_block_response_headers
functionDefaults to Empty

If the default CORS response headers are not sufficient, use this subroutine to customize the headers added to block responses resulting from CORS requests. If this subroutine is defined, the default CORS block headers are not added. Only the headers you set on obj are included.

Example
1# PX_CUSTOM
2sub px_custom_cors_set_custom_block_response_headers {
3 set obj.http.Access-Control-Allow-Origin = req.http.Origin;
4 set obj.http.Access-Control-Allow-Credentials = "true";
5 set obj.http.Access-Control-Allow-Methods = "GET, POST, OPTIONS";
6 set obj.http.Access-Control-Allow-Headers = "Content-Type, Authorization";
7}
px_cors_preflight_request_filter_enabled
booleanDefaults to false

Disables enforcement for CORS preflight requests. When set to true, CORS preflight requests will be pass through the Enforcer flow without triggering detection or block responses.

  • true: Filter out preflight requests
  • false: Don’t filter out preflight requests
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_cors_preflight_request_filter_enabled": "true",
5 # ...
6}
px_cors_preflight_handler_enabled
booleanDefaults to false

Whether to invoke px_custom_cors_preflight_handler.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_cors_preflight_handler_enabled": "true",
5 # ...
6}
px_custom_cors_preflight_handler
functionDefaults to Empty

A custom subroutine for handling CORS preflight requests. Use it to return a customized preflight response before enforcement. px_custom_cors_preflight_handler is invoked prior to determining whether to filter the request based on px_cors_preflight_request_filter_enabled. This lets you return customized responses for preflight requests that meet certain conditions and filter those that do not.

Example
1# PX_CUSTOM
2sub px_custom_cors_preflight_handler {
3 set obj.status = 204;
4 set obj.http.Access-Control-Allow-Origin = req.http.Origin;
5 set obj.http.Access-Control-Allow-Methods = req.method;
6 set obj.http.Access-Control-Allow-Headers = req.http.Access-Control-Request-Headers;
7 set obj.http.Access-Control-Allow-Credentials = "true";
8 set obj.http.Access-Control-Max-Age = "86400";
9}

Credentials Intelligence

These configurations let you extract and detect compromised credentials. They’re closely related to Credentials Intelligence-related features in Sightline Cyberfraud Defense.

At minimum, ensure the following are configured to enable Credential Intelligence:

px_login_credentials_extraction_enabled
booleanDefaults to false

Be sure to define a suffix for each endpoint (for example _0, _1) and append that suffix to each key. Pair this table with px_custom_is_login_request. The table is declared in PX_CUSTOM, or you can replace it with a Fastly dictionary of the same name.

Whether to enable the extraction and reporting of credentials from the Enforcer for Credential Intelligence.

  • true: Enable Credential Intelligence
  • false: Disable Credential Intelligence
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_login_credentials_extraction_enabled": "true",
5 # ...
6}
px_login_credentials_extraction
table

An array of configuration objects for each credential endpoint. Each element in the array is an object representing a distinct endpoint to which credentials are sent and includes:

  • How to identify these credential-bearing requests
  • How to extract the credentials from the request
  • How to determine if the request operation (login, signup, etc.) was successful based on the returned HTTP response

Click to expand the full properties list.

Example
1# PX_CUSTOM
2table px_login_credentials_extraction {
3 "path_0": "/login",
4 "protocol_0": "v2",
5 "method_0": "post",
6 "sent_through_0": "body",
7 "pass_field_0": "password",
8 "user_field_0": "username",
9
10 "path_1": "/sign-up",
11 "protocol_1": "multistep_sso",
12 "method_1": "post",
13 "sent_through_1": "custom",
14}
path
stringRequired

The path of the request that contains the credentials. Store an exact path in the px_login_credentials_extraction table. For regex matching, implement the logic in px_custom_is_login_request.

Example
1# PX_CUSTOM
2table px_login_credentials_extraction {
3 # ...
4 "path_0": "/sign-up",
5 # ...
6}
method
"post" | "put"Required

The HTTP method of the request that contains the credentials. Supports "post" and "put".

Example
1# PX_CUSTOM
2table px_login_credentials_extraction {
3 # ...
4 "method_0": "post",
5 # ...
6}
sent_through
"body" | "custom"Required

Whether the credentials should be extracted from the request body or via a defined custom callback.

  • "body": The credentials will be extracted according to the configured user_field and pass_field values from the request body. Body size is limited to 8K per Fastly limits. The Enforcer parses the request body based on the following Content-Type request header:
    • application/json
    • application/x-www-form-urlencoded
  • "custom": The credentials will be extracted by invoking px_custom_login_extraction_callback.
Example
1# PX_CUSTOM
2table px_login_credentials_extraction {
3 # ...
4 "sent_through_0": "body",
5 # ...
6}
user_field
string

Required if sent_through is set to "body". The name of the field containing the username in the request body.

On Fastly VCL, nested JSON fields are matched by leaf field name (period-separated paths are not required). For example, a body with { "user_info": { "username": "user123" } } can use user_field set to "username".

Example
1# PX_CUSTOM
2table px_login_credentials_extraction {
3 # ...
4 "sent_through_0": "body",
5 "user_field_0": "username",
6 # ...
7}
pass_field
string

Required if sent_through is set to "body". The name of the field containing the password in the request body.

On Fastly VCL, nested JSON fields are matched by leaf field name (period-separated paths are not required). For example, a body with { "authentication": { "password": "P@s$w0rD!" } } can use pass_field set to "password".

Example
1# PX_CUSTOM
2table px_login_credentials_extraction {
3 # ...
4 "sent_through_0": "body",
5 "pass_field_0": "password",
6 # ...
7}
protocol
"v2" | "multistep_sso" | "both"Defaults to "both"

Whether to process credentials as part of single or multiple HTTP requests. By default, the module tries to process requests depending on which credential fields were extracted. If omitted, the Enforcer uses px_credentials_intelligence_version.

  • "v2": Both username and password are present on the same HTTP request and must be extracted successfully to trigger Credential Intelligence.
  • "multistep_sso": The username and password are delivered on different HTTP requests. Either the username or password, but not both, must be extracted successfully to trigger Credential Intelligence.
  • "both": The username and password may be present on the same HTTP request or on different HTTP requests. If either username or password is successfully extracted, the Enforcer will send the credentials according to the multistep_sso protocol. If both username and password are successfully extracted, the Enforcer will send the credentials according to the v2 protocol.
Example
1# PX_CUSTOM
2table px_login_credentials_extraction {
3 # ...
4 "protocol_0": "v2",
5 # ...
6}
px_custom_is_login_request
function

Returns the credential endpoint suffix (for example _0 or _1) that matches the request path for px_login_credentials_extraction. Use this subroutine for exact or regex path matching.

Example
1# PX_CUSTOM
2sub px_custom_is_login_request STRING {
3 if (req.url.path == table.lookup(px_login_credentials_extraction, "path_0")) {
4 return "_0";
5 } else if (req.url.path ~ "^/sign-up") {
6 return "_1";
7 }
8}
px_custom_login_extraction_callback
function

Required if sent_through is set to "custom". A custom credential extraction subroutine that returns the raw credentials from the request. Use req.http.px-creds:endpoint-index to distinguish endpoints. Set req.http.px-creds:raw-username and req.http.px-creds:raw-password. If neither the username nor the password can be extracted, leave both unset.

Example
1# PX_CUSTOM
2sub px_custom_login_extraction_callback {
3 declare local var.username STRING;
4 declare local var.password STRING;
5
6 if (req.http.px-creds:endpoint-index == "_1") {
7 # set var.username and var.password from the request
8 }
9
10 if (var.username) {
11 set req.http.px-creds:raw-username = var.username;
12 }
13 if (var.password) {
14 set req.http.px-creds:raw-password = var.password;
15 }
16}
px_login_successful_reporting_method
"status" | "header" | "custom"Defaults to status

The method by which the Enforcer will determine whether the login request was successful.

  • "status": The Enforcer will determine if the login request was successful by evaluating the response status code against px_login_successful_status.
  • "header": The Enforcer will determine if the login request was successful when resp.http.x-px-login-successful is "1".
  • "custom": The Enforcer will determine if the login request was successful by invoking px_custom_set_login_successful_response_header.
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_login_successful_reporting_method": "custom",
5 # ...
6}
px_login_successful_status
stringDefaults to 200

The default HTTP status codes that indicate a successful login. This takes effect when the px_login_successful_reporting_method is set to status.

Fastly VCL supports a single status code. For multiple status codes, use custom reporting with px_custom_set_login_successful_response_header.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_login_successful_status": "202",
5 # ...
6}
px_custom_set_login_successful_response_header
function

Required if px_login_successful_reporting_method is set to "custom". A custom subroutine that inspects the HTTP response and indicates whether the login attempt was successful. Return "1" if the login succeeded or "0" otherwise. Invoked during vcl_deliver.

Example
1# PX_CUSTOM
2sub px_custom_set_login_successful_response_header STRING {
3 if (resp.http.custom-login-header == "login_successful") {
4 return "1";
5 }
6 return "0";
7}
px_send_raw_username_on_additional_s2s_activity
booleanDefaults to false

Whether to report the raw username on the additional_s2s activity.

  • false: The raw username will never be reported.
  • true: The raw username will only be reported if:
    • The credentials are compromised, and
    • The login request was successful.
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_send_raw_username_on_additional_s2s_activity": "true",
5 # ...
6}
px_additional_s2s_activity_header_enabled
booleanDefaults to false

Whether to attach the additional_s2s payload and URL as headers to the original request. This is done so that the additional_s2s activity can be enriched with the proper login_successful value and sent to the provided URL at a later stage. Enabling this configuration disables automatic sending of additional_s2s activity.

When set to true, the following headers are added to the origin request:

  • px-additional-activity: A JSON object containing the payload of the additional_s2s activity. The login_successful and http_status_code fields should be set prior to sending the activity.
  • px-additional-activity-url: The URL to which the additional_s2s payload should be sent as an HTTP POST request.
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_additional_s2s_activity_header_enabled": "true",
5 # ...
6}
px_credentials_intelligence_query_string
booleanDefaults to false

Whether to append compromised_credentials=true to the origin request URL when compromised credentials are identified. Unlike header-based signaling on other Enforcers, Fastly VCL can surface compromised credentials through the request query string.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_credentials_intelligence_query_string": "true",
5 # ...
6}
px_compromised_credentials_returned_status_response
stringDefaults to ""

When px_credentials_intelligence_query_string is enabled and a successful login used compromised credentials, set the client response status to this value.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_compromised_credentials_returned_status_response": "401",
5 # ...
6}
px_credentials_intelligence_version
"v2" | "multistep_sso" | "both"Defaults to bothDeprecated

The default credential hashing protocol applied to endpoints that do not specify a protocol field.

  • "v2": Both username and password are present on the same HTTP request and must be extracted successfully to trigger Credential Intelligence.
  • "multistep_sso": The username and password are delivered on different HTTP requests. Either the username or password, but not both, must be extracted successfully to trigger Credential Intelligence.
  • "both": The username and password may be present on the same HTTP request or on different HTTP requests. If either username or password is successfully extracted, the Enforcer will send the credentials according to the multistep_sso protocol. If both username and password are successfully extracted, the Enforcer will send the credentials according to the v2 protocol.

Prefer configuring protocol per endpoint in px_login_credentials_extraction.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_credentials_intelligence_version": "v2",
5 # ...
6}
stringDefaults to x-px-cookies

By default, the Enforcer extracts HUMAN cookies from the Cookie header. However, if these cookies are transferred on a different header, then that header’s name must be provided with this configuration.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_custom_cookie_header": "custom-human-cookies",
5 # ...
6}

Custom first party endpoints

These configurations let you use the Enforcer as a proxy for HUMAN servers and serve content to the browser from a first party endpoint. These are particularly useful when browser or extension restrictions that block JavaScript requests to other domains, such as adblockers, prevent the HUMAN Sensor from making requests to HUMAN’s backend. When this happens, it significantly limits HUMAN’s detection capabilities, so we recommend enabling these configurations to maintain full detection capabilities.

px_first_party_enabled
booleanDefaults to true

Whether to enable first party mode for Bot Defender or Sightline Cyberfraud Defense.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_first_party_enabled": "false",
5 # ...
6}
px_custom_first_party_prefix
stringDefaults to ""

Sets a custom prefix for first party routes to use in addition to the default prefix. By default, first party endpoints always begin with the Application ID without the initial “PX”. For example, if the ID is PX12345678, then all first party routes will take the form /12345678/*.

When configured, the Enforcer will respond to first party requests with endpoints matching the following patterns:

  • /<px_custom_first_party_prefix>/init.js
  • /<px_custom_first_party_prefix>/xhr/*
  • /<px_custom_first_party_prefix>/captcha/*

If empty, the configuration will use the default as described above.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_custom_first_party_prefix": "/custom-prefix",
5 # ...
6}
px_custom_first_party_sensor_endpoint
stringDefaults to ""

Customizes the entire first party Sensor script endpoint. By default, for an Application ID PX12345678, the first party endpoint is /12345678/init.js.

In addition to responding to requests that match this configured route, the Enforcer will also proxy first party requests that match the default pattern (/12345678/init.js) and patterns according to the custom prefix (/<px_custom_first_party_prefix>/init.js) if one is configured.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_custom_first_party_sensor_endpoint": "/human_sensor",
5 # ...
6}
px_custom_first_party_xhr_endpoint
stringDefaults to ""

Customizes the first party XHR endpoint. By default, for an Application ID PX12345678, the first party XHR endpoint is /12345678/xhr.

In addition to responding to requests that match this configured route, the Enforcer will also proxy first party requests that match the default pattern (/12345678/xhr/*) and patterns according to the custom prefix (/<px_custom_first_party_prefix>/xhr/*) if one is configured.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_custom_first_party_xhr_endpoint": "/human_xhr",
5 # ...
6}
px_custom_first_party_captcha_endpoint
stringDefaults to ""

Customizes the first party CAPTCHA endpoint. By default, for an Application ID PX12345678, the first party CAPTCHA endpoint is /12345678/captcha.

In addition to responding to requests that match this configured route, the Enforcer will also proxy first party requests that match the default pattern (/12345678/captcha/*) and patterns according to the custom prefix (/<px_custom_first_party_prefix>/captcha/*) if one is configured.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_custom_first_party_captcha_endpoint": "/human_captcha",
5 # ...
6}
px_custom_first_party_response_modifier
functionDefaults to Empty

Modifies first party responses in vcl_deliver using the client response object.

Example
1# PX_CUSTOM
2sub px_custom_first_party_response_modifier {
3 unset resp.http.Access-Control-Allow-Origin;
4 set resp.http.Strict-Transport-Security = "max-age=86400";
5}

Custom parameters

These configurations are related to custom parameters.

px_custom_add_custom_parameters
functionDefaults to Empty

Enriches activities sent from the Enforcer to HUMAN with additional custom parameters. This data can include user information, session IDs, or other data that HUMAN should have access to. There is a limit of 10 custom parameters (110). Set them on request headers named px-custom-param:<NUMBER>. Custom parameters must also be configured in the HUMAN Portal.

Example
1# PX_CUSTOM
2sub px_custom_add_custom_parameters {
3 set req.http.px-custom-param:1 = "test1";
4 set req.http.px-custom-param:2 = "test2";
5 set req.http.px-custom-param:3 = "3";
6}

Enforced routes

These configurations let you define specific routes that should be enforced by HUMAN when the Enforcer is in monitor mode. These routes will always be subject to the full Enforcer workflow, including blocking requests if necessary.

Primitive string values are treated as path prefixes. For example, /login also matches /login/callback.

px_custom_enforced_routes
function

A custom subroutine that lets you define which requests should be enforced based on custom logic, even when the Enforcer is in monitor mode.

  • Returns true: The request should be enforced.
  • Returns false (default): The request should proceed with the usual enforcement flow.
Example
1# PX_CUSTOM
2sub px_custom_enforced_routes BOOL {
3 if (req.url.path ~ {"^/enforced|^/checkout"}) {
4 return true;
5 }
6 return false;
7}

Extracted cookies

px_custom_extracted_cookies
functionDefaults to Empty

For each cookie name, the Enforcer will extract the cookie’s key-value pair and add it as a new field in the Risk API. This lets you include additional information to HUMAN’s detection mechanism if you’d like to.

Extract cookie values onto bereq.http.X-PX-<COOKIE_NAME> headers for HUMAN backend requests.

Example
1# PX_CUSTOM
2sub px_custom_extracted_cookies {
3 if (req.http.cookie:session_id && req.http.cookie:session_id != "") {
4 set bereq.http.X-PX-session_id = req.http.cookie:session_id;
5 }
6}

Filters

These configurations let you filter out certain requests or assets from the Enforcer. These values will be ignored by the Enforcer and will never be blocked.

Implement filter logic in PX_CUSTOM. A return value of true means the request is filtered from enforcement. A return value of false means the request should proceed with the usual enforcement flow.

px_custom_filter_by_extension
function

Filters out requests with the specified file extension. By default, HUMAN doesn’t enforce static assets such as images and documents to minimize unncessary API calls and computation, but you can configure this list at any time.

Filtering by extension only applies to GET and HEAD HTTP methods.

Default
1# PX_CUSTOM
2sub px_custom_filter_by_extension BOOL {
3 if ((req.request == "GET" || req.request == "HEAD") && req.url.ext ~ "^(css|bmp|tif|ttf|docx|woff2|js|pict|tiff|eot|xlsx|csv|eps|woff|xls|jpeg|jpg|doc|ejs|otf|pptx|gif|pdf|swf|svg|ps|ico|pls|midi|svgz|class|png|ppt|mid|webp|jar)$") {
4 return true;
5 }
6 return false;
7}
px_custom_filter_by_http_method
functionDefaults to Returns false

Filters out requests with the specified HTTP method to avoid unnecessary traffic in the Enforcer verification flow.

Example
1# PX_CUSTOM
2sub px_custom_filter_by_http_method BOOL {
3 if (req.request ~ "(?i)^(OPTIONS|TRACE)$") {
4 return true;
5 }
6 return false;
7}
px_custom_filter_by_ip
functionDefaults to Returns false

Filters out requests with the specified IP address to avoid unnecessary traffic in the Enforcer verification flow.

The easiest way to implement this subroutine is to declare and use a Fastly Access Control List (ACL) as shown in the example below.

Example
1# PX_CUSTOM
2acl Filtered_IPs {
3 "123.123.123.123";
4 "12.12.12.0"/24;
5}
6
7sub px_custom_filter_by_ip BOOL {
8 if (req.http.Fastly-Client-IP ~ Filtered_IPs) {
9 return true;
10 }
11 return false;
12}
px_custom_filter_by_route
functionDefaults to Returns false

Filters out requests with the specified route to avoid unnecessary traffic in the Enforcer verification flow. Requests to these specified routes will never be blocked regardless of their risk score and will never generate risk or async activities. Primitive string values are treated as path prefixes. For example, /login also matches /login/callback.

Example
1# PX_CUSTOM
2sub px_custom_filter_by_route BOOL {
3 if (req.url.path ~ {"^/health|^/static/"}) {
4 return true;
5 }
6 return false;
7}
px_custom_filter_by_user_agent
functionDefaults to Returns false

Filters out requests with the specified user agent to avoid unnecessary traffic in the Enforcer verification flow. Primitive string values are case-sensitive and require an exact user-agent string.

Example
1# PX_CUSTOM
2sub px_custom_filter_by_user_agent BOOL {
3 if (req.http.User-Agent ~ {"Filtered_UA"}) {
4 return true;
5 }
6 return false;
7}

GraphQL support

These configurations let the Enforcer extract GraphQL data from requests so that it can enforce these requests in the same way as other types of traffic.

px_graphql_enabled
booleanDefaults to true

Whether to parse and report information about GraphQL operations on incoming requests. When true, all POST requests with routes that match the prefixes configured in px_custom_is_graphql_route will have their bodies parsed for GraphQL operations.

  • true: Enable GraphQL support
  • false: Disable GraphQL support
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_graphql_enabled": "false",
5 # ...
6}
px_custom_is_graphql_route
function

A custom subroutine that returns whether the request should be considered a GraphQL route.

Default
1# PX_CUSTOM
2sub px_custom_is_graphql_route BOOL {
3 if (req.url.path ~ {"/graphql"}) {
4 return true;
5 }
6 return false;
7}
px_sensitive_graphql_operation_names
stringDefaults to ""

A space-separated list of operation names that should be considered sensitive. Some routes may be more prone to bot attacks than others, such as routes that execute payments or handle personal information. You can configure these names as sensitive to ensure more stringent protection.

If one or more GraphQL operations has a name matching this list, the Enforcer will trigger a Risk API call even if the request contains a valid, unexpired cookie.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_sensitive_graphql_operation_names": "SensitiveOperation1 SensitiveOperation2",
5 # ...
6}
px_sensitive_graphql_operation_types
'query' | 'mutation' | 'subscription'Defaults to ""

A space-separated list of operation types that should be considered sensitive. Some routes may be more prone to bot attacks than others, such as routes that execute payments or handle personal information. You can configure these routes as sensitive to ensure a more stringent protection.

If one or more GraphQL operations on an HTTP request has a type matching this list, the Enforcer will trigger a Risk API call even if the request contains a valid, unexpired cookie.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_sensitive_graphql_operation_types": "mutation subscription",
5 # ...
6}
px_custom_check_sensitive_graphql_operation
function

This configuration is meant for cases that require more complex logic. We recommended you use px_sensitive_graphql_operation_types and px_sensitive_graphql_operation_names for most cases.

A custom subroutine that returns a boolean indicating whether the request should be treated as sensitive given the GraphQL data that was extracted by the enforcer. If it returns true, the Enforcer will trigger a Risk API call even if the request contains a valid, unexpired cookie. Extracted values are available on:

Example
1# PX_CUSTOM
2sub px_custom_check_sensitive_graphql_operation BOOL {
3 if (req.http.px-graphql:operation-type ~ "mutation" || req.http.px-graphql:operation-name ~ "SensitiveOperation") {
4 return true;
5 }
6 return false;
7}

Header data enrichment

These configurations let you add headers to incoming requests with additional data.

px_data_enrichment_header_name
stringDefaults to ""

Adds a header to the incoming request with the configured header name and the JSON-stringified data enrichment object as the value. If empty or if data enrichment has not been enabled for your policy, no header will be set. To view available data and enable this feature, see Data classification enrichment.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_data_enrichment_header_name": "x-px-data-enrichment",
5 # ...
6}

HUMAN Challenge customization

These configurations let you customize the HUMAN Challenge block page.

px_css_ref
stringDefaults to ""

A way to include a custom CSS file to the block page.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_css_ref": "https://example.com/custom.css",
5 # ...
6}
px_js_ref
stringDefaults to ""

A way to include custom JavaScript to the block page. This script will run after the default JavaScript scripts.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_js_ref": "https://example.com/custom.js",
5 # ...
6}
stringDefaults to ""

Adds a custom logo to the HUMAN Challenge block page via URL.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_custom_logo": "https://example.com/logo.png",
5 # ...
6}
px_custom_block_page_content
functionDefaults to Empty

Returns a string containing custom HTML for the HUMAN Challenge block page. Block page template values are available on req.http.X-PX-template:*.

Example
1# PX_CUSTOM
2sub px_custom_block_page_content STRING {
3 declare local var.block-page-content STRING;
4 set var.block-page-content = {"<!DOCTYPE html><html><body>Access denied</body></html>"};
5 return var.block-page-content;
6}
px_custom_web_block_page_response
functionDefaults to Empty

Overrides the default web block response status and headers.

Example
1# PX_CUSTOM
2sub px_custom_web_block_page_response {
3 set obj.status = 403;
4 set obj.response = "Forbidden";
5 set obj.http.Content-Type = "text/html";
6}
px_custom_rate_limit_block_page
functionDefaults to Empty

Overrides the default rate-limit block response.

Example
1# PX_CUSTOM
2sub px_custom_rate_limit_block_page {
3 set obj.status = 429;
4 set obj.response = "Too Many Requests";
5 set obj.http.Content-Type = "text/html";
6}
px_custom_create_advanced_blocking_response
functionDefaults to Empty

Overrides the default Advanced Blocking Response (ABR) JSON block response status and headers.

Example
1# PX_CUSTOM
2sub px_custom_create_advanced_blocking_response {
3 set obj.status = 403;
4 set obj.response = "Forbidden";
5 set obj.http.Content-Type = "application/json";
6}

Logging

The default installation method adds Fastly logging endpoints automatically, but if you are manually installing the Enforcer instead, see our logging endpoint setup instructions for more information.

px_async_activities_logger
stringDefaults to PX-Async-Activities

Name of the logging endpoint used to send asynchronous activities.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_async_activities_logger": "Human-Async-Activities",
5 # ...
6}
px_telemetry_activity_logger
stringDefaults to PX-Telemetry

Name of the logging endpoint used to send telemetry activities.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_telemetry_activity_logger": "Human-Telemetry",
5 # ...
6}
px_debug_syslog_name
stringDefaults to PX-Debug

Name of the logging endpoint for debug logs when px_logger_severity is debug.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_debug_syslog_name": "Human-Debug",
5 # ...
6}
px_error_syslog_name
stringDefaults to PX-Error

Name of the logging endpoint for error logs when px_logger_severity is error.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_error_syslog_name": "Human-Error",
5 # ...
6}
px_debug_probability
stringDefaults to 1

When logger severity is debug, one out of every N requests generates logs, where N is this value. "1" logs every request (1/1), while "100" logs about 1% of requests (1/100).

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_debug_probability": "100",
5 # ...
6}

Monitored routes

px_custom_monitored_routes
function

A set of endpoints to be monitored rather than blocked by the Enforcer, even when the Enforcer is in active_blocking mode.

  • Returns true: The request should behave as if the Enforcer is in monitor mode, even when the module mode is active_blocking.
  • Returns false (default): The request should proceed with the usual enforcement flow.
Example
1# PX_CUSTOM
2sub px_custom_monitored_routes BOOL {
3 if (req.url.path ~ {"^/monitored|^/experiments/"}) {
4 return true;
5 }
6 return false;
7}

Override configs

px_override_configs
functionDefaults to Empty

Whenever possible, set configuration values in the px_configs table rather than adjusting them at runtime.

Adjusts HUMAN configuration based on runtime values by modifying req.http.px-cfg header fields. See the PX VCL file for available px-cfg keys.

Example
1# PX_CUSTOM
2sub px_override_configs {
3 if (client.geo.country_code == "GB") {
4 set req.http.px-cfg:css-ref = "https://example.co.uk/style.css";
5 }
6}

Pre-clean

The Enforcer stores configuration and metadata on request headers during the Fastly request lifecycle. Before origin requests in vcl_miss / vcl_pass, those headers are cleaned. Use pre-clean to copy values you still need.

px_enable_pre_clean
booleanDefaults to false

Whether to invoke px_custom_pre_clean.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_enable_pre_clean": "true",
5 # ...
6}
px_custom_pre_clean
functionDefaults to Empty

Runs immediately before HUMAN metadata headers are removed from the backend request.

Example
1# PX_CUSTOM
2sub px_custom_pre_clean {
3 set bereq.http.X-Human-Score = if(req.http.px-ctx:pass-reason, "0", "100");
4 set bereq.http.X-Human-Uuid = req.http.px-ctx:uuid;
5}
px_secured_pxhd_enabled
booleanDefaults to false

The PX Hashed Data (PXHD or _pxhd) cookie links the first risk request with the browser activities as detected by the Sensor for better user tracking. It can also add more information that’s shared between the HUMAN Collector, Enforcer, and Sensor. This configuration determines whether the Secure cookie attribute is added when setting the PXHD cookie.

See Use of cookies & web storage for more information.

  • true: Adds the Secure attribute to the PXHD cookie
  • false: Does not add the Secure attribute to the PXHD cookie
Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_secured_pxhd_enabled": "true",
5 # ...
6}

Remote Configuration

Remote Configuration lets you update your Enforcer’s configuration from the HUMAN portal rather than interacting with the Enforcer package directly.

Remote Configuration requires access to the Fastly API and Fastly Dictionaries. These are included by default in the default installation method. If you are manually installing the Enforcer instead, see our manual installation instructions for more information.

px_logger_auth_token
stringDefaults to ""Required

An alternative to the basic logger configuration. This sends Enforcer logs to HUMAN’s logging service if a specific header is present on the request. This is particularly useful for expedited debugging, diagnosis, and resolution of any integration or Enforcer-related issues.

Contact HUMAN to recieve your token.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_logger_auth_token": "<LOGGER_AUTH_TOKEN>",
5 # ...
6}
px_remote_config_auth_token
stringDefaults to ""Required

The token used to authenticate the Enforcer with the HUMAN Remote Configuration service.

Contact HUMAN to receive your token.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_remote_config_auth_token": "<REMOTE_CONFIG_AUTH_TOKEN>",
5 # ...
6}
px_remote_config_id
stringDefaults to ""Required

The ID associated with the Remote Configuration.

Contact HUMAN to receive your ID.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_remote_config_id": "<REMOTE_CONFIG_ID>",
5 # ...
6}
px_fastly_api_token
stringDefaults to ""Required

Store this value in the px_private private dictionary, not in the px_configs table.

Fastly API key with permission to update the Fastly service (global scope for that service). Create a token via the Fastly Console, CLI, or API.

Example
$# <dictionary_id> must belong to the dictionary named px_private
$curl https://api.fastly.com/service/<service_id>/dictionary/<dictionary_id>/item \
> -H 'Fastly-Key: <fastly_api_token>' \
> -d 'item_key=px_fastly_api_token&item_value=<fastly_api_token>'
px_enforcer_config_rdata_id
stringDefaults to ""Required

Dictionary ID for the px_enforcer_config_rdata dictionary. Look it up via CLI or API.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_enforcer_config_rdata_id": "<DICTIONARY_ID>",
5 # ...
6}

Response custom parameters

These configurations enrich async activities with values derived from the origin response.

px_custom_add_response_custom_parameters
functionDefaults to Empty

A subroutine that uses the origin response to set up to ten fields: custom parameters 11 through 20. These are merged into page_requested, additional_s2s, and simulated block activities. There is a limit of ten response custom parameters. Invoked in vcl_deliver after the backend response is available on resp. On Fastly VCL, set them on request headers named px-custom-param:<NUMBER>.

Example
1# PX_CUSTOM
2sub px_custom_add_response_custom_parameters {
3 set req.http.px-custom-param:11 = resp.http.X-Response-Id;
4 set req.http.px-custom-param:12 = std.itoa(resp.status);
5}

Risk backend overwrite

px_set_custom_risk_backend_overwrite
functionDefaults to Empty

Changes the backend used for Risk API requests (for example, to adjust timeouts by region). Define any backends other than PX_API yourself. Called during vcl_pass when a Risk API request is needed.

Example
1# PX_CUSTOM
2backend PX_RISK_API_LOW_TIMEOUT {
3 # ...
4}
5
6sub px_set_custom_risk_backend_overwrite {
7 if (server.region !~ {"US"}) {
8 set req.backend = PX_RISK_API_LOW_TIMEOUT;
9 }
10}

Sensitive headers removal

px_custom_unset_sensitive_headers
function

Specifies certain headers that should not be forwarded to any other destination, including the HUMAN Detector. While HUMAN’s detection system will continue to use these headers to determine whether to block or not, the specified headers won’t be forwarded from the Enforcer, won’t appear in Enforcer activities, and won’t be sent to any other IP if the Enforcer acts as a proxy.

Called before Enforcer backend requests. Unset headers from bereq. If you do not customize this subroutine, Cookie and Cookies are removed by default.

Example
1# PX_CUSTOM
2sub px_custom_unset_sensitive_headers {
3 unset bereq.http.Cookie;
4 unset bereq.http.Cookies;
5 unset bereq.http.X-Sensitive-Token;
6}

Sensitive routes

px_custom_check_sensitive_route
function

A set of prefixes for all routes that should be considered sensitive.

  • Returns true: The request should always trigger a Risk API call, even with a valid cookie.
  • Returns false (default): The request should proceed with the usual enforcement flow.
Example
1# PX_CUSTOM
2sub px_custom_check_sensitive_route BOOL {
3 if (req.url.path ~ {"^/login|^/checkout"}) {
4 return true;
5 }
6 return false;
7}

Users identifiers

These configurations let you extract user identifiers from a JWT carried on the request either in a cookie or a header. They’re closely related to the Accounts and Account Takeover or Fake Account features in Sightline Cyberfraud Defense.

The Enforcer reads the JWT from the configured cookie first, then from the configured header if cookie extraction does not succeed. Field names support dot notation for nested JWT claim (for example, product.id).

stringDefaults to ""

The name of the cookie that contains the JWT token that HUMAN should extract user identifiers from.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_jwt_cookie_name": "auth",
5 # ...
6}
stringDefaults to ""

The field name in the JWT object, extracted from the JWT cookie, that contains the user ID to be extracted and reported.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_jwt_cookie_user_id_field_name": "nameID",
5 # ...
6}
px_jwt_header_name
stringDefaults to ""

The name of the header that contains the JWT token that HUMAN should extract user identifiers from.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_jwt_header_name": "x-jwt-authorization",
5 # ...
6}
px_jwt_header_user_id_field_name
stringDefaults to ""

The field name in the JWT object, extracted from the JWT header, that contains the user ID to be extracted and reported.

Example
1# PX_CONFIGS
2table px_configs {
3 # ...
4 "px_jwt_header_user_id_field_name": "sub",
5 # ...
6}
px_custom_extract_jwt_additional_fields
functionDefaults to Empty

The field names in the JWT object that should be extracted and reported in addition to the user ID. On Fastly VCL, implement this as a subroutine that returns additional JWT fields as a string of "fieldName":"fieldValue" pairs. The decoded JWT is available on req.http.px-jwt:Token-Decoded.

Example
1# PX_CUSTOM
2sub px_custom_extract_jwt_additional_fields STRING {
3 declare local var.px-additional-key-value-pairs STRING;
4 if (req.http.px-jwt:Token-Decoded ~ {"("exp":"[^"]*")"}) {
5 set var.px-additional-key-value-pairs = re.group.1;
6 }
7 if (req.http.px-jwt:Token-Decoded ~ {"("iss":"[^"]*")"}) {
8 set var.px-additional-key-value-pairs = if (var.px-additional-key-value-pairs, var.px-additional-key-value-pairs ",", "") re.group.1;
9 }
10 return var.px-additional-key-value-pairs;
11}