2016-11-08 13:57:29 +00:00
|
|
|
DeviceAtlas Device Detection
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
In order to add DeviceAtlas Device Detection support, you would need to download
|
2021-02-16 11:37:45 +00:00
|
|
|
the API source code from https://deviceatlas.com/deviceatlas-haproxy-module.
|
2024-01-25 09:09:07 +00:00
|
|
|
Once extracted :
|
2016-11-08 13:57:29 +00:00
|
|
|
|
2024-01-25 09:09:07 +00:00
|
|
|
$ make TARGET=<target> USE_DEVICEATLAS=1 DEVICEATLAS_SRC=<path to the API root folder>
|
2016-11-08 13:57:29 +00:00
|
|
|
|
|
|
|
Optionally DEVICEATLAS_INC and DEVICEATLAS_LIB may be set to override the path
|
|
|
|
to the include files and libraries respectively if they're not in the source
|
2024-01-25 09:09:07 +00:00
|
|
|
directory. Also, in the case the api cache support is not needed and/or a C++ toolchain
|
|
|
|
could not be used, DEVICEATLAS_NOCACHE is available.
|
|
|
|
|
|
|
|
$ make TARGET=<target> USE_DEVICEATLAS=1 DEVICEATLAS_SRC=<path to the API root folder> DEVICEATLAS_NOCACHE=1
|
|
|
|
|
|
|
|
However, if the API had been installed beforehand, DEVICEATLAS_SRC
|
|
|
|
can be omitted. Note that the DeviceAtlas C API version supported is from the 3.x
|
2024-02-22 09:12:27 +00:00
|
|
|
releases series (3.2.1 minimum recommended).
|
2016-11-08 13:57:29 +00:00
|
|
|
|
2019-05-24 08:25:45 +00:00
|
|
|
For HAProxy developers who need to verify that their changes didn't accidentally
|
2019-04-26 12:02:28 +00:00
|
|
|
break the DeviceAtlas code, it is possible to build a dummy library provided in
|
2021-04-02 14:19:39 +00:00
|
|
|
the addons/deviceatlas/dummy directory and to use it as an alternative for the
|
|
|
|
full library. This will not provide the full functionalities, it will just allow
|
2019-04-26 12:02:28 +00:00
|
|
|
haproxy to start with a deviceatlas configuration, which generally is enough to
|
|
|
|
validate API changes :
|
|
|
|
|
2024-01-25 09:09:07 +00:00
|
|
|
$ make TARGET=<target> USE_DEVICEATLAS=1 DEVICEATLAS_SRC=$PWD/addons/deviceatlas/dummy
|
2019-04-26 12:02:28 +00:00
|
|
|
|
2016-11-08 13:57:29 +00:00
|
|
|
These are supported DeviceAtlas directives (see doc/configuration.txt) :
|
|
|
|
- deviceatlas-json-file <path to the DeviceAtlas JSON data file>.
|
|
|
|
- deviceatlas-log-level <number> (0 to 3, level of information returned by
|
|
|
|
the API, 0 by default).
|
|
|
|
- deviceatlas-property-separator <character> (character used to separate the
|
|
|
|
properties produced by the API, | by default).
|
2024-01-25 09:09:07 +00:00
|
|
|
- deviceatlas-cache-size <number> (number of cache entries, 0 by default).
|
2016-11-08 13:57:29 +00:00
|
|
|
|
|
|
|
Sample configuration :
|
|
|
|
|
|
|
|
global
|
|
|
|
deviceatlas-json-file <path to json file>
|
|
|
|
|
|
|
|
...
|
|
|
|
frontend
|
|
|
|
bind *:8881
|
|
|
|
default_backend servers
|
|
|
|
|
|
|
|
There are two distinct methods available, one which leverages all HTTP headers
|
|
|
|
and one which uses only a single HTTP header for the detection. The former
|
|
|
|
method is highly recommended and more accurate. There are several possible use
|
|
|
|
cases.
|
|
|
|
|
|
|
|
# To transmit the DeviceAtlas data downstream to the target application
|
|
|
|
|
|
|
|
All HTTP headers via the sample / fetch
|
|
|
|
|
|
|
|
http-request set-header X-DeviceAtlas-Data %[da-csv-fetch(primaryHardwareType,osName,osVersion,browserName,browserVersion,browserRenderingEngine)]
|
|
|
|
|
2019-05-24 08:25:45 +00:00
|
|
|
Single HTTP header (e.g. User-Agent) via the converter
|
2016-11-08 13:57:29 +00:00
|
|
|
|
|
|
|
http-request set-header X-DeviceAtlas-Data %[req.fhdr(User-Agent),da-csv-conv(primaryHardwareType,osName,osVersion,browserName,browserVersion,browserRenderingEngine)]
|
|
|
|
|
|
|
|
# Mobile content switching with ACL
|
|
|
|
|
|
|
|
All HTTP headers
|
|
|
|
|
|
|
|
acl is_mobile da-csv-fetch(mobileDevice) 1
|
|
|
|
|
|
|
|
Single HTTP header
|
|
|
|
|
|
|
|
acl device_type_tablet req.fhdr(User-Agent),da-csv-conv(primaryHardwareType) "Tablet"
|
|
|
|
|
2024-01-25 09:09:07 +00:00
|
|
|
Note that the JSON download scheduler is now part of the API's package, it is recommended
|
|
|
|
to read its documentation. Note it needs to be started before HAProxy.
|
2022-01-27 18:13:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
Please find more information about DeviceAtlas and the detection methods at
|
|
|
|
https://deviceatlas.com/resources .
|