51Degrees NGINX Plus Certified Module Combines Patented Device Detection with the Simplicity of NGINX

Original: https://www.nginx.com/blog/51degrees-nginx-plus-certified-module-combines-device-detection-with-nginx/

51Degrees often receives queries from new clients who are using NGINX Plus load balancing and need to implement a quality device‑intelligence solution for high fidelity analytics, increased conversion rates, and quality user experiences. The 51Degrees NGINX Plus Certified Module provides the starting point for that complete service, combining the fastest patented device detection with the simplicity of NGINX Plus.


With the 51Degrees NGINX Plus Certified Module, customers can perform device detection at the network layer. Thus they benefit from the speed and accuracy available in the C‑language API, while enabling any applications downstream to utilize the device data regardless of the programming language they are written in.

Why Use Device Detection?

Device detection enables you to improve the user experience by delivering content that is:

Optimizing, Personalizing, and Analyzing with 51Degrees in Programmatic Advertising

Consider the programmatic advertising world as an example: here, placing and presenting the right ads to the right viewer at the right time is incredibly complex. Many ads are dynamically selected for individual users through a real‑time bidding process that occurs behind the scenes, within milliseconds of the user sending a request. Part of this process includes identifying the device and its characteristics for targeting purposes. Companies need sub‑millisecond speed, consistency, and accuracy in their data sets. Leading programmatic advertisers and publishers like Tencent, Seznam, News24.com, Adform, Centro, and Adyoulike use 51Degrees to process many millions of bid requests per second.

Example of display ads on mobile and desktop from Sanook, Tencent Thailand’s leading online news site

Why Implement 51Degrees Device Intelligence?

Companies select 51Degrees because of the speed and accuracy of our solution. We are the only commercial open source solution available. All source code is licensed under the Mozilla Public License version 2.

Key 51Degrees metrics (numbers accurate at time of publication)

How Device Detection Works

51Degrees' NGINX‑hosted, high‑performance device detection works out the type of device in less than 1 millisecond, using fingerprints (HTTP headers including User-Agent) representing circa 1 million combinations of browser versions, operating system versions, and device models. Your website returns a page optimized for the precise screen size and device type, ensuring that the tech does not get in the way of performance and user experience.

Device data analyzed by 51Degrees enables delivery of customized content

Speed of response and accuracy are important for delivering an optimal user experience, personalization, and high‑fidelity analytics. 51Degrees performs with better than 99.9% matching accuracy. Its algorithm is capable of more than 22 million detections per second on a single CPU!

Device Combinations

51Degrees has a growing database of approximately 1 million device combinations. 51Degrees adds to this database every day, providing information such as retail price, vendor, screen size, OS version, device age, browser, currency, and many more permutations of device properties.

Three key components are used in the process:

A way to visualize this is as a cube with these components as dimensions. The cube is always expanding, as new device models come into the market, and new versions of operating systems, browsers, and apps come into use. 51Degrees data provides global coverage.

Key components of device combinations

Configuring the 51Degrees NGINX Plus Certified Module

Installing the 51Degrees NGINX Plus Certified Module requires no changes to the existing web server implementation. All the processing work is done during NGINX Plus’ request cycle, and the properties of the device are simply passed to the web server as additional HTTP headers. In addition to User-Agent matching, the module supports matching against multiple HTTP headers with no extra code, to catch tricky browsers like Opera Mini and the hugely popular UC Browser.

The 51Degrees NGINX Plus Certified Module can be used with NGINX Plus R9 (open source 1.9.13) and later. NGINX Plus R11 (open source 1.11.5) introduced the capability to compile dynamic modules independently, and we provide prebuilt modules for reference in the nginx/modules directory of our GitHub repo. To build a module for other NGINX Plus releases, see the instructions in the module README.

Note: As standard our GitHub repository contains a Lite data file for on‑premises deployments which is only pulled if you have Git LFS installed. To compare the available data‑file options, see Our Licenses & Pricing.

If required, you can download our Enhanced data file from the website after subscribing and replace the existing reference, as shown in the example below, in your local installation.

Enabling the Module

You enable 51Degrees device detection on an NGINX Plus server with just one line in the configuration, defining the data file. Add the 51D_filePath directive in the http block:

51D_filePath path/to/51Degrees.dat;

Then you can add device properties as additional request headers by adding the 51D_match_all directive in a location or server block. This example adds an additional request header named x-device which contains the values of the listed properties.

51D_match_all x-device DeviceType,PlatformName,HardwareName;

No device‑detection solution provides 100% accuracy. With 51Degrees the metrics about the accuracy of the match can also be retrieved by by adding the 51D_match_all with the metric properties Method, Difference, and Rank:

51D_match_all x-metrics DeviceId,Method,Difference,Rank;

Where the results are suspect, the consuming application might revert to default behavior or exclude the data from the analysis.

With these directives in the configuration, two headers are added to all incoming requests. The first header, x-device, contains information about the device. The second header, x-metrics, contains match metrics, which indicate the accuracy of the match and the popularity of the device combination.

Carrying out device detection in this way makes web optimization easier by removing the need for any software integration on an existing website. All that is needed is an if statement such as if tablet or if smartphone. The latency for a request when using the 51Degrees NGINX Plus module is as little as 0.001 milliseconds on an i7 or similar processor.

Full benchmarking results can be found in the developer documentation on our website.

Video Tutorial

In February 2018 we published a blog containing a video tutorial for developers which explains how to set up our device‑detection solution on a Linux machine using NGINX Plus. It demonstrates how to add properties to call from the data file and check that the results are being returned as response headers on the site.

This video tutorial does not cover installing NGINX Plus, but instructions are provided in the NGINX Plus Admin Guide, which also provides instructions for building open source NGINX from source.

About 51Degrees

51Degrees provides device intelligence for over 1.5 million websites around the world, including global brands like Disney, Tencent, Seznam, News24.com, Adform, Centro, and eBay, along with well‑known content management platforms like Sitecore and Liferay.

Since launching in 2011, our patented solution has changed the device‑detection industry by being the first to introduce native app support, pricing data, and meaningful metrics such as device combinations and accuracy metrics. Read more about our industry firsts.

51Degrees’ unique algorithm provides a solution that can meet the sub‑millisecond performance demanded of a high traffic‑volume environment without sacrificing accuracy. The 51Degrees NGINX Plus Certified Module comes with free access to the 51Degrees Lite data file which contains 62 device properties such as IsMobile, ScreenPixelsWidth and height, PlatformName (operating system), and more. Subscription‑based options with weekly and daily data file updates are available. For those wanting access to properties like price and age of device, these are included in our Enterprise data file which contains over 222 device properties and about 1 million device combinations.

More Resources

The 51Degrees NGINX Plus Certified Module
NGINX developer documentation on the 51Degrees website
51Degrees Device Data file comparisons – Property Dictionary
Enhanced data file subscription options – Pricing and Licensing
51Degrees User-Agent Tester

To get started with the 51Degrees NGINX Plus Certified Module, register for a free trial today. You can try NGINX Plus for free also.

Retrieved by Nick Shadrin from nginx.com website.