51DegreesTM

51Degrees NGINX Module

Ben Shillito

6/29/2016 11:26 AM

C NGINX Development News

The new NGINX module has now been released as beta

Please refer to our latest blog on NGINX. The 51Degrees NGINX module is certified and live since this blog was written.

NGINX is a load balancing reverse proxy which is written to be very fast. It is used mainly in systems that see a lot of traffic and need to route requests to multiple servers, but has been used in a wide variety of systems as well.

The new 51Degrees NGINX module combines patented device detection with the simplicity of NGINX. Detection can be carried out on an NGINX load balancing server with just one line in the configuration and installation requires no changes to the existing web server implementation. With all the work being done in NGINX’s request cycle, the properties of the device are simply passed to the web server as additional HTTP headers. As well as User-Agent matching, the module supports multiple HTTP header matching with no extra code in order to catch tricky browsers like Opera Mini.

A simple example of how the module can be seen below.

http { Server { Location / { 51D_match_all x-device DeviceType,PlatformName,HardwareName; 51D_match_all x-metrics DeviceId,Method,Rank; ... } } }

Here the two headers are added to all incoming requests. The first header “x-device” contains information about the device, the second “x-metrics” contains match metrics indicating the accuracy of the match, and the popularity of the device.

Carrying out device detection in this way makes web optimisation 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 time penalty for a request when using the 51Degrees NGINX module is as little as 0.001 ms on an i7 or similar processor.

Full benchmarking results can be found at https://51Degrees.com/Support/Documentation/APIs/C-V32/Benchmarks.

Full installation, test, and usage instructions can be found at https://github.com/51Degrees/Device-Detection/tree/master/nginx.