blob: 4ecb44a4d157d119a5d18721eba635d88075a5c8 [file] [log] [blame]
Willy Tarreau29b25312016-11-08 14:57:29 +01001DeviceAtlas Device Detection
2----------------------------
3
4In order to add DeviceAtlas Device Detection support, you would need to download
5the API source code from https://deviceatlas.com/deviceatlas-haproxy-module and
6once extracted :
7
8 $ make TARGET=<target> USE_PCRE=1 USE_DEVICEATLAS=1 DEVICEATLAS_SRC=<path to the API root folder>
9
10Optionally DEVICEATLAS_INC and DEVICEATLAS_LIB may be set to override the path
11to the include files and libraries respectively if they're not in the source
12directory.
13
14These are supported DeviceAtlas directives (see doc/configuration.txt) :
15 - deviceatlas-json-file <path to the DeviceAtlas JSON data file>.
16 - deviceatlas-log-level <number> (0 to 3, level of information returned by
17 the API, 0 by default).
18 - deviceatlas-property-separator <character> (character used to separate the
19 properties produced by the API, | by default).
20
21Sample configuration :
22
23 global
24 deviceatlas-json-file <path to json file>
25
26 ...
27 frontend
28 bind *:8881
29 default_backend servers
30
31There are two distinct methods available, one which leverages all HTTP headers
32and one which uses only a single HTTP header for the detection. The former
33method is highly recommended and more accurate. There are several possible use
34cases.
35
36# To transmit the DeviceAtlas data downstream to the target application
37
38All HTTP headers via the sample / fetch
39
40 http-request set-header X-DeviceAtlas-Data %[da-csv-fetch(primaryHardwareType,osName,osVersion,browserName,browserVersion,browserRenderingEngine)]
41
42Single HTTP header (e.g. User-Agent) via the convertor
43
44 http-request set-header X-DeviceAtlas-Data %[req.fhdr(User-Agent),da-csv-conv(primaryHardwareType,osName,osVersion,browserName,browserVersion,browserRenderingEngine)]
45
46# Mobile content switching with ACL
47
48All HTTP headers
49
50 acl is_mobile da-csv-fetch(mobileDevice) 1
51
52Single HTTP header
53
54 acl device_type_tablet req.fhdr(User-Agent),da-csv-conv(primaryHardwareType) "Tablet"
55
56
57Please find more information about DeviceAtlas and the detection methods at https://deviceatlas.com/resources .