$is_tablet
The $is_tablet variable is set by the device-type module in NGINX to indicate whether a request originates from a tablet device. It is set to 1 if the device is identified as a tablet, and 0 otherwise.
Type
boolean (1/0)
Possible values
1: The request is from a tablet device.0: The request is not from a tablet device.
Examples
Using $is_tablet in a map for Device-Specific Content
This example shows how to use $is_tablet in a map to set a variable for serving tablet-specific content.
map $is_tablet $tablet_content {
1 /tablet/index.html;
0 /default/index.html;
}
server {
location / {
try_files $tablet_content =404;
}
}
Adding a Custom Header for Tablet Requests
Add a custom header to responses for tablet devices to assist in analytics or debugging.
server {
location / {
if ($is_tablet) {
add_header X-Device-Type "Tablet";
}
proxy_pass http://backend;
}
}
Logging Tablet Access in log_format
Log requests from tablet devices using a custom log format.
log_format tablet_log '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'"Tablet: $is_tablet"';
access_log /var/log/nginx/tablet_access.log tablet_log;
server {
location / {
proxy_pass http://backend;
}
}