Device detection
ScientiaMobile WURFL InFuze
This page applies to:
- HAProxy Enterprise 1.7r2 and newer
- This module is unavailable for Arm processors
The WURFL module provides device detection services using the ScientiaMobile InFuze database.
Install the WURFL InFuze module Jump to heading
-
Log into your account at the ScientiaMobile website and subscribe to WURFL InFuze. Follow the installation instructions in the WURFL InFuze for C: User Guide to install the API on your HAProxy Enterprise server.
-
Copy the WURFL InFuze device detection database (XML file) to your HAProxy Enterprise server (for example
/etc/hapee-3.2/wurfl.xml). -
Install the WURFL module according to your platform:
nixsudo apt-get install hapee-<VERSION>-lb-wurflnixsudo apt-get install hapee-<VERSION>-lb-wurflExample for HAProxy Enterprise 3.2r1:
nixsudo apt-get install hapee-3.2r1-lb-wurflnixsudo apt-get install hapee-3.2r1-lb-wurflnixsudo yum install hapee-<VERSION>-lb-wurflnixsudo yum install hapee-<VERSION>-lb-wurflExample for HAProxy Enterprise 3.2r1:
nixsudo yum install hapee-3.2r1-lb-wurflnixsudo yum install hapee-3.2r1-lb-wurflnixsudo zypper install hapee-<VERSION>-lb-wurflnixsudo zypper install hapee-<VERSION>-lb-wurflExample for HAProxy Enterprise 3.2r1:
nixsudo zypper install hapee-3.2r1-lb-wurflnixsudo zypper install hapee-3.2r1-lb-wurflnixsudo pkg install hapee-<VERSION>-lb-wurflnixsudo pkg install hapee-<VERSION>-lb-wurflExample for HAProxy Enterprise 3.2r1:
nixsudo pkg install hapee-3.2r1-lb-wurflnixsudo pkg install hapee-3.2r1-lb-wurfl -
In the
globalsection of your configuration, add the following lines:haproxyglobal...module-load hapee-lb-wurfl.sowurfl-data-file /etc/hapee-3.2/wurfl.xmlwurfl-information-list wurfl_id model_namewurfl-cache-size 100000haproxyglobal...module-load hapee-lb-wurfl.sowurfl-data-file /etc/hapee-3.2/wurfl.xmlwurfl-information-list wurfl_id model_namewurfl-cache-size 100000In this example:
wurfl-data-filesets the path to the WURFL data file.wurfl-information-listlist of WURFL capabilities, virtual capabilities, and property names to use in injected HTTP headers. Separate each value with a space. See the WURFL InFuze documentation for values that you can use.wurfl-cache-sizesets the number of entries to keep in the LRU (least recently used) cache. The LRU cache speeds up lookup operations on User-Agent strings by storing previously processed lookups.
-
Optional: Set the
wurfl-information-list-separatordirective to change the separator to use between values returned from the database. By default, it uses a comma (,).haproxyglobal...module-load hapee-lb-wurfl.sowurfl-data-file /etc/hapee-3.2/wurfl.xmlwurfl-information-list wurfl_id model_namewurfl-cache-size 100000wurfl-information-list-separator :haproxyglobal...module-load hapee-lb-wurfl.sowurfl-data-file /etc/hapee-3.2/wurfl.xmlwurfl-information-list wurfl_id model_namewurfl-cache-size 100000wurfl-information-list-separator : -
Optional: Set the
wurfl-patch-filedirective to the file paths to WURFL patch definitions. You can have as many as necessary, and the API applies them in the order they appear in the configuration file. Separate each value with a space. -
Optional: Set the
wurfl-engine-modedirective to target a WURFL engine. It can be eitherperformance, which is the default, oraccuracy. -
Optional: Set the
wurfl-useragent-prioritydirective to eitherplainto prioritize using the plain User-Agent orsideloaded_browserto prioritize the sideloaded browser User-Agent. The default issideloaded_browser. -
Reload the configuration to apply the changes.
nixsudo systemctl reload hapee-3.2-lbnixsudo systemctl reload hapee-3.2-lb
Use WURFL InFuze Jump to heading
After installing the module, use the following directives to perform database lookups.
wurfl-get Jump to heading
Use the fetch method wurfl-get to perform a lookup in the database that returns the values of the specified properties. You must declare these properties beforehand with the wurfl-information-list global directive.
Syntax:
textwurfl-get(<prop>[,<prop>*])
textwurfl-get(<prop>[,<prop>*])
In this example, we create an HTTP request header that contains device information.
haproxyfrontend wwwbind :80mode httphttp-request set-header X-WURFL-Properties %[wurfl-get(wurfl_id,model_name)]
haproxyfrontend wwwbind :80mode httphttp-request set-header X-WURFL-Properties %[wurfl-get(wurfl_id,model_name)]
wurfl-get-all Jump to heading
Use the fetch method wurfl-get-all to perform a lookup in the database that returns values for all properties that the wurfl-information-list directive declared.
Syntax:
textwurfl-get-all()
textwurfl-get-all()
In this example we create an HTTP request header that contains all the device properties.
haproxyfrontend wwwbind :80mode httphttp-request set-header X-WURFL-All %[wurfl-get-all()]
haproxyfrontend wwwbind :80mode httphttp-request set-header X-WURFL-All %[wurfl-get-all()]
Update the database during runtime Jump to heading
This section applies to:
- HAProxy Enterprise 1.9r1 and newer
Use the WURFL Update module to keep contents of the device detection database current. This allows you to keep multiple load balancers synced with the latest data.
-
Install a web server of your choice and host the database file at a URL HAProxy Enterprise can access. For example, host the file at
http://192.168.0.1:8000/wurfl.xml.gz. -
Install the package
hapee-3.2r1-lb-wurfl-update:nixsudo apt-get install hapee-<VERSION>-lb-wurfl-updatenixsudo apt-get install hapee-<VERSION>-lb-wurfl-updateExample for HAProxy Enterprise 3.2r1:
nixsudo apt-get install hapee-3.2r1-lb-wurfl-updatenixsudo apt-get install hapee-3.2r1-lb-wurfl-updatenixsudo yum install hapee-<VERSION>-lb-wurfl-updatenixsudo yum install hapee-<VERSION>-lb-wurfl-updateExample for HAProxy Enterprise 3.2r1:
nixsudo yum install hapee-3.2r1-lb-wurfl-updatenixsudo yum install hapee-3.2r1-lb-wurfl-updatenixsudo zypper install hapee-<VERSION>-lb-wurfl-updatenixsudo zypper install hapee-<VERSION>-lb-wurfl-updateExample for HAProxy Enterprise 3.2r1:
nixsudo zypper install hapee-3.2r1-lb-wurfl-updatenixsudo zypper install hapee-3.2r1-lb-wurfl-updatenixsudo pkg install hapee-<VERSION>-lb-wurfl-updatenixsudo pkg install hapee-<VERSION>-lb-wurfl-updateExample for HAProxy Enterprise 3.2r1:
nixsudo pkg install hapee-3.2r1-lb-wurfl-updatenixsudo pkg install hapee-3.2r1-lb-wurfl-update -
In the
globalsection of your configuration, add the following directives:haproxyglobal...module-load hapee-lb-wurfl-update.sowurfl-update url http://192.168.0.1:8000/wurfl.xml.gz delay 24h loghaproxyglobal...module-load hapee-lb-wurfl-update.sowurfl-update url http://192.168.0.1:8000/wurfl.xml.gz delay 24h logBe sure to specify the port number where your file is hosted, for example
8000as in the example above. With this configuration, HAProxy Enterprise downloads the database every 24 hours and displays a message in the logs when it succeeds, or when it encounters an error during the update.Learn more about wurfl-update
The directive
wurfl-updatesupports the following syntax:textwurfl-update url <url> [delay <u> | xdelay <u s b r>] [timeout <t>] [retries <n>] [checksum | modified] [hash] [source <addr>[:<port>]] [log] [dontlog-normal] [param*]textwurfl-update url <url> [delay <u> | xdelay <u s b r>] [timeout <t>] [retries <n>] [checksum | modified] [hash] [source <addr>[:<port>]] [log] [dontlog-normal] [param*]where:
Argument Description url <url>Required. Specifies the database update URL. delay <u>Specifies the period between each attempt to download a new database version. The delay is a simplified version of the xdelaykeyword.xdelay <u s b r><u>specifies the period between each attempt to download a new database version;<s>specifies the initial (first) download delay;<b>specifies the delay between the download of each element of the database; If the download fails,<r>determines the delay for the next attempt; Default values are: u = 5m, s = 5s, b = 10s, and r = 30s; If the load balancer cannot download the new version after three attempts, it cancels and discards the download until the next time interval defined by<u>.timeout <t>Specifies the HTTP connection timeout in milliseconds (default) for attempts to download a new database version. The value can be any other unit if you add a unit suffix. It defaults to 5000 milliseconds. retries <n>Specifies the number of retries to download a new WURFL database version. If not set, the global retriesvalue applies (defaults to 3).checksumIf set, this determines the use of the SHA1control sum to verify that the recently downloaded database is identical to the current one. If it is, then live-reload of the database does not occur, thereby preserving the cached contents (if using caching).hashIf set, enables authentication of the downloaded data; Each file undergoing upgrade must have the associated file with SHA1checksum; ASHA1checksum file has the extension.sha1; The typical way of creating aSHA1checksum file is:sha1sum file > file.sha1.modifiedSpecifies the use of the time from the Last-Modifiedresponse HTTP header. Example: checks whether to update the data using theIf-Modified-Sincerequest HTTP header.source <addr>[:<port>]Sets the source address for outgoing connections. <addr>is the IPv4 address the load balancer binds to before it connects to a server; The default value is 0.0.0.0 to let the system select the most optimal address to reach its destination;<port>is optional; The default value of zero means that the system selects a free port; It does not support port ranges.logSpecifies whether to log operation errors. dontlog-normalDeactivates logging of successful updates. param*Lists other server parameters that are useful for configuring SSL features. The options
checksumandmodifiedare mutually exclusive. If you define them at the same time, the optionmodifiedautomatically switches off and a warning message prints when HAProxy Enterprise starts.
Runtime API Jump to heading
It is possible to manage the WURFL InFuze module via the Runtime API.
wurfl-update force-update Jump to heading
Prerequisites
This command becomes available after you have installed both the WURFL and WURFL Update modules.
The WURFL InFuze update module will update its database based on the interval you specified in the configuration. Use wurfl-update force-update to force an immediate update of the WURFL InFuze database.
In this example, we force an update of the database.
nixecho "wurfl-update force-update" | sudo socat stdio unix-connect:/var/run/hapee-3.2/hapee-lb.sock
nixecho "wurfl-update force-update" | sudo socat stdio unix-connect:/var/run/hapee-3.2/hapee-lb.sock
outputtextWURFL: forcing update in 5m
outputtextWURFL: forcing update in 5m
wurfl-update status Jump to heading
Prerequisites
This command becomes available after you have installed both the WURFL and WURFL Update modules.
You can check the status of the update using the wurfl-update status command. Note that while the update is processing, the status will show the progress:
nixecho "wurfl-update status" | sudo socat stdio unix-connect:/var/run/hapee-3.2/hapee-lb.sock
nixecho "wurfl-update status" | sudo socat stdio unix-connect:/var/run/hapee-3.2/hapee-lb.sock
outputtextWURFL InFuze module status------------------------------------------------------------------------------initialized: yesData updateconfiguration: /etc/hapee-2.7/hapee-lb.cfg:43url: http://192.168.64.1:8000/http status count: 0 0 0 0 7 / 0period/delay: 1d / 5s 10s 5suse cksum/hash/mod: no / no / noreload/retry count: 0 0 2 / 7 2reload time: <NEVER> / <NEVER> / 2023-08-08 14:25:37currently updating: wurfl.xml.gzstatus/retry: 0 / 2data size: 0 / 0 (0.0%)dur/time left: 8s / 1s
outputtextWURFL InFuze module status------------------------------------------------------------------------------initialized: yesData updateconfiguration: /etc/hapee-2.7/hapee-lb.cfg:43url: http://192.168.64.1:8000/http status count: 0 0 0 0 7 / 0period/delay: 1d / 5s 10s 5suse cksum/hash/mod: no / no / noreload/retry count: 0 0 2 / 7 2reload time: <NEVER> / <NEVER> / 2023-08-08 14:25:37currently updating: wurfl.xml.gzstatus/retry: 0 / 2data size: 0 / 0 (0.0%)dur/time left: 8s / 1s
wurfl-update show Jump to heading
Prerequisites
This command becomes available after you have installed both the WURFL and WURFL Update modules.
Use the wurfl-update show command to display the configuration of the WURFL Update module. The output of this command includes information about the configured database file and its update status.
Below, we retrieve the status information for our configured database file:
nixecho "wurfl-update show" | sudo socat stdio unix-connect:/var/run/hapee-3.2/hapee-lb.sock
nixecho "wurfl-update show" | sudo socat stdio unix-connect:/var/run/hapee-3.2/hapee-lb.sock
outputtext# wurfl-update configuration# url: next updatehttp://192.168.0.1:8000/wurfl.xml.gz: 23h58m
outputtext# wurfl-update configuration# url: next updatehttp://192.168.0.1:8000/wurfl.xml.gz: 23h58m
Do you have any suggestions on how we can improve the content of this page?