Device detection
ScientiaMobile WURFL InFuze
Available since
- HAProxy Enterprise 1.7r2
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.0/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.0r1:
nixsudo apt-get install hapee-3.0r1-lb-wurflnixsudo apt-get install hapee-3.0r1-lb-wurflnixsudo yum install hapee-<VERSION>-lb-wurflnixsudo yum install hapee-<VERSION>-lb-wurflExample for HAProxy Enterprise 3.0r1:
nixsudo yum install hapee-3.0r1-lb-wurflnixsudo yum install hapee-3.0r1-lb-wurflnixsudo zypper install hapee-<VERSION>-lb-wurflnixsudo zypper install hapee-<VERSION>-lb-wurflExample for HAProxy Enterprise 3.0r1:
nixsudo zypper install hapee-3.0r1-lb-wurflnixsudo zypper install hapee-3.0r1-lb-wurflnixsudo pkg install hapee-<VERSION>-lb-wurflnixsudo pkg install hapee-<VERSION>-lb-wurflExample for HAProxy Enterprise 3.0r1:
nixsudo pkg install hapee-3.0r1-lb-wurflnixsudo pkg install hapee-3.0r1-lb-wurfl -
In the
global
section of your configuration, add the following lines:haproxyglobalmodule-load hapee-lb-wurfl.sowurfl-data-file /etc/hapee-3.0/wurfl.xmlwurfl-information-list wurfl_id model_namewurfl-cache-size 100000haproxyglobalmodule-load hapee-lb-wurfl.sowurfl-data-file /etc/hapee-3.0/wurfl.xmlwurfl-information-list wurfl_id model_namewurfl-cache-size 100000In this example:
wurfl-data-file
sets the path to the WURFL data file.wurfl-information-list
list 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-size
sets 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-separator
directive to change the separator to use between values returned from the database. By default, it uses a comma (,
).haproxyglobalmodule-load hapee-lb-wurfl.sowurfl-data-file /etc/hapee-3.0/wurfl.xmlwurfl-information-list wurfl_id model_namewurfl-cache-size 100000wurfl-information-list-separator :haproxyglobalmodule-load hapee-lb-wurfl.sowurfl-data-file /etc/hapee-3.0/wurfl.xmlwurfl-information-list wurfl_id model_namewurfl-cache-size 100000wurfl-information-list-separator : -
Optional: Set the
wurfl-patch-file
directive 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-mode
directive to target a WURFL engine. It can be eitherperformance
, which is the default, oraccuracy
. -
Optional: Set the
wurfl-useragent-priority
directive to eitherplain
to prioritize using the plain User-Agent orsideloaded_browser
to prioritize the sideloaded browser User-Agent. The default issideloaded_browser
. -
Reload the configuration to apply the changes.
nixsudo systemctl reload hapee-3.0-lbnixsudo systemctl reload hapee-3.0-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:
text
wurfl-get(<prop>[,<prop>*])
text
wurfl-get(<prop>[,<prop>*])
In this example, we create an HTTP request header that contains device information.
haproxy
frontend wwwbind :80mode httphttp-request set-header X-WURFL-Properties %[wurfl-get(wurfl_id,model_name)]
haproxy
frontend 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:
text
wurfl-get-all()
text
wurfl-get-all()
In this example we create an HTTP request header that contains all the device properties.
haproxy
frontend wwwbind :80mode httphttp-request set-header X-WURFL-All %[wurfl-get-all()]
haproxy
frontend wwwbind :80mode httphttp-request set-header X-WURFL-All %[wurfl-get-all()]
Update the database during runtime Jump to heading
Available since
- HAProxy Enterprise 1.9r1
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.0r1-lb-wurfl-update
:nixsudo apt-get install hapee-<VERSION>-lb-wurfl-updatenixsudo apt-get install hapee-<VERSION>-lb-wurfl-updateExample for HAProxy Enterprise 3.0r1:
nixsudo apt-get install hapee-3.0r1-lb-wurfl-updatenixsudo apt-get install hapee-3.0r1-lb-wurfl-updatenixsudo yum install hapee-<VERSION>-lb-wurfl-updatenixsudo yum install hapee-<VERSION>-lb-wurfl-updateExample for HAProxy Enterprise 3.0r1:
nixsudo yum install hapee-3.0r1-lb-wurfl-updatenixsudo yum install hapee-3.0r1-lb-wurfl-updatenixsudo zypper install hapee-<VERSION>-lb-wurfl-updatenixsudo zypper install hapee-<VERSION>-lb-wurfl-updateExample for HAProxy Enterprise 3.0r1:
nixsudo zypper install hapee-3.0r1-lb-wurfl-updatenixsudo zypper install hapee-3.0r1-lb-wurfl-updatenixsudo pkg install hapee-<VERSION>-lb-wurfl-updatenixsudo pkg install hapee-<VERSION>-lb-wurfl-updateExample for HAProxy Enterprise 3.0r1:
nixsudo pkg install hapee-3.0r1-lb-wurfl-updatenixsudo pkg install hapee-3.0r1-lb-wurfl-update -
In the
global
section of your configuration, add the following directives:haproxyglobalmodule-load hapee-lb-wurfl-update.sowurfl-update url http://192.168.0.1:8000/wurfl.xml.gz delay 24h loghaproxyglobalmodule-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
8000
as 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-update
supports 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 xdelay
keyword.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 retries
value applies (defaults to 3).checksum
If set, this determines the use of the SHA1
control 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).hash
If set, enables authentication of the downloaded data; Each file undergoing upgrade must have the associated file with SHA1
checksum; ASHA1
checksum file has the extension.sha1
; The typical way of creating aSHA1
checksum file is:sha1sum file > file.sha1
.modified
Specifies the use of the time from the Last-Modified
response HTTP header. Example: checks whether to update the data using theIf-Modified-Since
request 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.log
Specifies whether to log operation errors. dontlog-normal
Deactivates logging of successful updates. param*
Lists other server parameters that are useful for configuring SSL features. The options
checksum
andmodified
are mutually exclusive. If you define them at the same time, the optionmodified
automatically 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 specifed 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.
nix
echo "wurfl-update force-update" | sudo socat stdio unix-connect:/var/run/hapee-3.0/hapee-lb.sock
nix
echo "wurfl-update force-update" | sudo socat stdio unix-connect:/var/run/hapee-3.0/hapee-lb.sock
outputtext
WURFL: forcing update in 5m
outputtext
WURFL: 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:
nix
echo "wurfl-update status" | sudo socat stdio unix-connect:/var/run/hapee-3.0/hapee-lb.sock
nix
echo "wurfl-update status" | sudo socat stdio unix-connect:/var/run/hapee-3.0/hapee-lb.sock
outputtext
WURFL 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
outputtext
WURFL 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:
nix
echo "wurfl-update show" | sudo socat stdio unix-connect:/var/run/hapee-3.0/hapee-lb.sock
nix
echo "wurfl-update show" | sudo socat stdio unix-connect:/var/run/hapee-3.0/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?