http-loop-detect #
ngx_http_loop_detect_module allows NGINX to use the CDN-Loop header to prevent request loops.
Source: upstream source
Directives
loop_detect #
syntax: loop_detect on | off; · default: loop_detect off; · context: http, server, location
Enables or disables the loop detection for the current scope. When enabled, the module checks the CDN-Loop header to track the number of hops and blocks requests exceeding the allowed limit.
loop_detect_cdn_id #
syntax: loop_detect_cdn_id string; · default: loop_detect_cdn_id openresty; · context: http, server, location
Sets the unique identifier for your clusters. This identifier is used to parse and track loops in the CDN-Loop header.
loop_detect_max_allow_loops #
syntax: loop_detect_max_allow_loops number; · default: loop_detect_max_allow_loops 10; · context: http, server, location
Sets the maximum number of allowed loops before blocking the request. The number must be greater than 0.
loop_detect_status #
syntax: loop_detect_status code; · default: loop_detect_status 508; · context: http, server, location
Sets the HTTP status code returned when a request exceeds the allowed loop limit. The code must be between 400 and 599 (client or server errors).
Example
http {
# Enable the module in a location block
loop_detect on;
loop_detect_cdn_id my_cdn_id;
loop_detect_status 508;
loop_detect_max_allow_loops 10;
server {
listen 80;
server_name example.com;
location / {
proxy_set_header CDN-Loop $loop_detect_proxy_add_cdn_loop;
proxy_pass http://example.upstream.com;
}
}
}