Willy Tarreau | 29b2531 | 2016-11-08 14:57:29 +0100 | [diff] [blame] | 1 | DeviceAtlas Device Detection |
| 2 | ---------------------------- |
| 3 | |
| 4 | In order to add DeviceAtlas Device Detection support, you would need to download |
| 5 | the API source code from https://deviceatlas.com/deviceatlas-haproxy-module and |
| 6 | once extracted : |
| 7 | |
| 8 | $ make TARGET=<target> USE_PCRE=1 USE_DEVICEATLAS=1 DEVICEATLAS_SRC=<path to the API root folder> |
| 9 | |
| 10 | Optionally DEVICEATLAS_INC and DEVICEATLAS_LIB may be set to override the path |
| 11 | to the include files and libraries respectively if they're not in the source |
| 12 | directory. |
| 13 | |
| 14 | These 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 | |
| 21 | Sample configuration : |
| 22 | |
| 23 | global |
| 24 | deviceatlas-json-file <path to json file> |
| 25 | |
| 26 | ... |
| 27 | frontend |
| 28 | bind *:8881 |
| 29 | default_backend servers |
| 30 | |
| 31 | There are two distinct methods available, one which leverages all HTTP headers |
| 32 | and one which uses only a single HTTP header for the detection. The former |
| 33 | method is highly recommended and more accurate. There are several possible use |
| 34 | cases. |
| 35 | |
| 36 | # To transmit the DeviceAtlas data downstream to the target application |
| 37 | |
| 38 | All 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 | |
| 42 | Single 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 | |
| 48 | All HTTP headers |
| 49 | |
| 50 | acl is_mobile da-csv-fetch(mobileDevice) 1 |
| 51 | |
| 52 | Single HTTP header |
| 53 | |
| 54 | acl device_type_tablet req.fhdr(User-Agent),da-csv-conv(primaryHardwareType) "Tablet" |
| 55 | |
| 56 | |
| 57 | Please find more information about DeviceAtlas and the detection methods at https://deviceatlas.com/resources . |