DeviceAtlas
The DeviceAtlas module provides device detection services using the DeviceAtlas database.
Install the DeviceAtlas module
Log into your account at the DeviceAtlas website and download the Enterprise API C library. Copy libda.so to your HAProxy Enterprise server into the directory /lib/x86_64-linux-gnu/.
From your DeviceAtlas account, download the Device Data (JSON) file. Copy it to your HAProxy Enterprise server (e.g. /etc/hapee-1.9/deviceatlas.json).
-
Install the DeviceAtlas module according to your platform:
$ # On Debian/Ubuntu $ sudo apt-get install hapee-1.9r1-lb-da
$ # On CentOS/RedHat/Oracle $ sudo yum install hapee-1.9r1-lb-da
$ # On SUSE $ sudo zypper install hapee-1.9r1-lb-da
$ # On FreeBSD $ sudo pkg install hapee-1.9r1-lb-da
-
In the
global
section of the HAProxy Enterprise configuration file, add the following:global module-load hapee-lb-da.so deviceatlas-json-file
/etc/hapee-1.9/deviceatlas.json Reload the HAProxy Enterprise configuration to apply the changes.
Global directives
The module adds the following global
directives:
Directive | Description |
---|---|
| Loads a DeviceAtlas database. |
| Specifies the separator to use within the output. Defaults to a pipe symbol (|). |
| Sets the log level, which can be set to a number between 0 and 3 (defaults to 0):
|
| The name of the DeviceAtlas Client-side Component cookie, if using client-side properties. Defaults to DAPROPS. |
Fetches and Converters
da-csv-fetch
Use the fetch method da-csv-fetch
to perform a lookup in the database that returns the values of the specified properties.
Syntax
da-csv-fetch(<prop>[,<prop>*])
Example: Create an HTTP request header that contains device information
frontend www
bind :80
mode http
http-request set-header X-DeviceInfo %[da-csv-fetch(primaryHardwareType,osName,osVersion,browserName,browserVersion,browserRenderingEngine)]
Example: Define an ACL named is_mobile
frontend www
bind :80
mode http
acl is_mobile da-csv-fetch(mobileDevice) 1
da-csv-conv
Use the converter da-csv-conv
to perform a lookup in the database that returns the values of the specified properties. It takes the User-Agent header as an input parameter:
Syntax:
da-csv-conv(<prop>[,<prop>*])
Example: Create an HTTP request header that contains device information
frontend www
bind :80
mode http
http-request set-header X-DeviceInfo %[req.hdr(user-agent),da-csv-conv(primaryHardwareType,osName,osVersion,browserName,browserVersion,browserRenderingEngine)]
Update the database during runtime
Use the DeviceAtlas Update module to keep the contents of the device detection database current. This allows you to keep multiple instances of HAProxy Enterprise synced with the latest data.
Install a Web server of your choice and host the database file at a URL where HAProxy Enterprise can access. For example, host the file at http://192.168.122.1/deviceatlas.json.
-
Install the package
hapee-1.9r1-lb-da-update
:$ # On Debian/Ubuntu $ sudo apt-get install hapee-1.9r1-lb-da-update
$ # On CentOS/RedHat/Oracle $ sudo yum install hapee-1.9r1-lb-da-update
$ # On SUSE $ sudo zypper install hapee-1.9r1-lb-da-update
$ # On FreeBSD $ sudo pkg install hapee-1.9r1-lb-da-update
-
Add the following lines to the
global
section of your configuration file, where the URL hosts an updated version of the file:global # ... other global settings module-load hapee-lb-da-update.so deviceatlas-update url
http://192.168.122.1/deviceatlas.json delay 24h log
With this configuration, HAProxy Enterprise downloads the database every 24 hours and displays a message in the logs when it succeeds or if it encountered errors during the update.
deviceatlas-update
The deviceatlas-update
directive enables updating the database over HTTP from a specified URL. Updating a database with a newer version invalidates any cached lookups (if caching is used), unless you enable checksum
and the new and old database contents are identical.
The directive supports the following syntax:
deviceatlas-update url <url>
[delay <u> | xdelay <u s b r>]
[timeout <t>]
[retries <n>]
[checksum]
[hash]
[modified]
[source <addr>[:<port>]]
[log]
[dontlog-normal]
[param*]
where:
| Required. Specifies the database update URL. The updated data can be either JSON or precompiled JSON. |
| Specifies the period between each attempt to download a new database version. The delay is a simplified version of the |
|
|
| Specifies the HTTP connection timeout for attempts to download a new database vers - The value is set in milliseconds by default, but you can set it to any other unit if you add a unit suffix to the number. - Defaults to 5 seco |
| Specifies the number of retries to download a new DeviceAtlas database version. If not set, the global |
| If set, determines the use of the |
| If set, enables authentication of the downloaded d - Each file undergoing upgrade must have the associated file with |
| Specifies the use of the time from the |
| Sets the source address for outgoing connecti - |
| Specifies whether to log operation errors. |
| Deactivates logging of successful updates. |
| Lists other server parameters that are useful for configuring SSL features. |
Runtime API
The following Runtime API commands are available:
| Sets the debug level. The default is 7. Use this command only when the module runs in debug mode; in normal use, it has no significance. |
| Provides instrumentation describing space usage.
|
| Displays the module configuration. |
| Displays the module status. |
| Runs the update at a time specified with the
|
Next up
WURFL InFuze