Aller au contenu

$is_tv

The $is_tv variable is set by the device-type module to indicate whether the request originates from a Smart TV. It holds a boolean value.

Type

Boolean (1/0)

Possible values

  • 1: The request is from a Smart TV.
  • 0: The request is not from a Smart TV.

Examples

Conditional Access Control

Restrict access to certain content for Smart TV users.

server {
    location /premium-content {
        if ($is_tv) {
            return 403 "Access restricted for Smart TV users";
        }
        proxy_pass http://backend;
    }
}

Custom Header for Backend

Add a custom header to inform the backend about the device type.

server {
    location / {
        proxy_set_header X-Is-TV $is_tv;
        proxy_pass http://backend;
    }
}

Cache Key Variation

Vary the cache key based on whether the request is from a Smart TV.

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