loop_detect_cdn_id
The loop_detect_cdn_id directive specifies a unique identifier for your CDN cluster to track request loops.
Description
The loop_detect_cdn_id directive is part of the ngx_http_loop_detect_module in NGINX, which aims to prevent request loops that can occur when utilizing Content Delivery Networks (CDNs). This directive allows you to set a unique identifier for your specific CDN cluster, which is necessary for the proper parsing of the CDN-Loop header. The identifier assists NGINX in managing and tracking the number of requests that have traversed through the CDN, ensuring compliance with the configured loop detection settings.
When this directive is specified, the value is used in conjunction with the HTTP headers associated with the CDN. NGINX will parse the CDN-Loop header, which tracks how many times a request has been forwarded through different CDN nodes. Each time a request is passed along, NGINX will check against the unique identifier set with loop_detect_cdn_id to determine if the maximum allowed hops have been exceeded, as governed by the loop_detect_max_allow_loops directive. If the maximum is surpassed, the request will receive a designated status code, which can be set using the loop_detect_status directive.
Config Example
location / {
loop_detect on;
loop_detect_cdn_id my_cdn_id;
loop_detect_max_allow_loops 10;
proxy_set_header CDN-Loop $loop_detect_proxy_add_cdn_loop;
proxy_pass http://example.upstream.com;
}Not setting a unique cdn_id could lead to incorrect loop detection when multiple CDNs are used together.
Ensure that the loop_detect directive is enabled in the appropriate context for loop_detect_cdn_id to take effect.