$browser_version
The $browser_version variable holds the full version string of the browser making the request. It is set by the device-type module when a request is processed.
Type
string
Possible values
120.0.0.0: Represents the complete version string of the browser. This value indicates the specific version of the browser in use.
Examples
Using $browser_version in a log_format
Log the browser version for each request.
http {
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$browser_version"';
access_log /var/log/nginx/access.log main;
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
}
Setting a custom header with $browser_version
Pass the browser version to the backend server.
server {
listen 80;
location / {
proxy_set_header X-Browser-Version $browser_version;
proxy_pass http://backend;
}
}
Conditional response based on $browser_version
Return a specific response for certain browser versions.
server {
listen 80;
location / {
if ($browser_version = "120.0.0.0") {
return 200 "Special content for version 120.0.0.0";
}
proxy_pass http://backend;
}
}
Related variables
- $browser_name: The name of the browser.
- $browser_family: The family of the browser.