$is_console
The $is_console variable is part of the device-type module for NGINX. It indicates whether the incoming HTTP request originates from a gaming console. This variable is set to 1 if the request is from a console, otherwise, it is 0.
Type
boolean (1/0)
Possible values
1: The request is from a gaming console.0: The request is not from a gaming console.
Examples
Using $is_console in a map
This example demonstrates how to use $is_console in a map to set a custom header for console users.
map $is_console $console_user {
1 "true";
0 "false";
}
server {
location / {
add_header X-Console-User $console_user;
}
}
Cache Key Composition
Vary the cache key based on whether the request is from a gaming console.
server {
location / {
proxy_cache_key "$scheme$request_uri|console:$is_console";
proxy_pass http://backend;
}
}
Access Control Based on Device Type
Restrict access to certain content for gaming consoles.
server {
location /restricted-content {
if ($is_console) {
return 403 "Access restricted for gaming consoles.";
}
proxy_pass http://backend;
}
}