Pular para conteúdo

$is_wearable

The $is_wearable variable is set by the device-type module in NGINX. It indicates whether the incoming HTTP request originates from a wearable device.

Type

Boolean (1/0)

Possible values

  • 1: The request is from a wearable device.
  • 0: The request is not from a wearable device.

Examples

Access Control for Wearable Devices

Restrict access to certain content for wearable devices.

server {
    location /restricted-content {
        if ($is_wearable) {
            return 403 "Access denied for wearable devices";
        }
        proxy_pass http://backend;
    }
}

Logging Wearable Device Access

Log requests from wearable devices for analytics purposes.

http {
    log_format wearable_log 'Wearable access: $remote_addr - $is_wearable';
    access_log /var/log/nginx/wearable_access.log wearable_log;

    server {
        location / {
            proxy_pass http://backend;
        }
    }
}

Cache Key Composition

Create a cache key that varies based on whether the request is from a wearable device.

http {
    proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=my_cache:10m;

    server {
        location / {
            proxy_cache my_cache;
            proxy_cache_key "$scheme$request_uri|$is_wearable";
            proxy_pass http://backend;
        }
    }
}