Load Balancing for NGINX Plus with WURFL InFuze

A version of this blog post originally appeared on the ScientiaMobile blog.

Editor – In April 2017, NGINX, Inc. launched the NGINX Plus Certified Module program for third‑party partners who build, deliver, and fully support modules for NGINX Plus platform, opening up additional features and application delivery management use cases for NGINX Plus customers. The functionality of an NGINX Certified Module is fully supported by the module vendor.

WURFL InFuze is a great example of extending application delivery management to dynamically support responsive web design for multiple device types. Below is a guest blog post from Ken Jones of ScientiaMobile about its new WURFL NGINX Plus Certified Module.

NGINX provides flexible, software‑based, high‑availability load balancing and an application delivery platform. And now with the WURFL InFuze for NGINX Plus Certified Module, you can quickly inject WURFL’s device intelligence into NGINX Plus’ application delivery logic.

NGINX Load Balancing Based on Smartphone, Tablet, or Other Device Form Factor

WURFL provides a number of options for load balancing criteria within open source NGINX or NGINX Plus. We can implement load balancing by operating system, browser type, or the price of the smartphone. In our following example (which will work for both open source NGINX and NGINX Plus), we load balance based on the device’s form factor.

To begin testing this scenario, you will need to edit the default NGINX configuration file, typically located at /etc/nginx/nginx.conf.

We separate traffic into three streams: smartphone, tablets, and other devices (such as desktop, smart TV, etc.). NGINX Plus can redirect those streams to specific servers.

# This is an example of how to configure NGINX to be used with WURFL Device Detection module.
# This configuration performs a redirection to different backends based on WURFL detection
# In this scenario we have three backend pools:
# - One for SMARTPHONE devices: SmartphonePool (
# - One for TABLET devices: TabletPool (
# - One for any other type of client (desktop, smartTV, etc.): GeneralPurposePool (
# Uncomment this line if you are using NGINX Plus or you compiled WURFL module with
# 'configure --add-dynamic-module' (WURFL API version or above / NGINX OSS 1.9.11 or above).
#load_module modules/ngx_http_wurfl_module.so;

worker_processes 1;

error_log logs/error.log info;
pid logs/nginx.pid;

events {
worker_connections 512;

http {

# the backends pool for requests from smartphones
upstream SmartphonePool {

# the backends pool for requests from tablets
upstream TabletPool {

# the backends pool for requests from other client types
upstream GeneralPurposePool {

# WURFL root definition, one per config. User MUST specify this path for WURFL engine
# to start correctly.
wurfl_root /usr/share/wurfl/wurfl.zip;

# Increase the variable hash size
variables_hash_max_size 1024;
variables_hash_bucket_size 1024;

wurfl_cache_double_lru 10000,3000;

# the WURFL virtual capability that determines if a device is a mobile phone
wurfl_request_capability is_smartphone;
wurfl_request_capability is_tablet;

# Map to different upstream backends based on concatenation of is_smartphone and is_tablet
# (pipe separated). $backend_pool_name contains the upstream name based on is_phone value.

map $wurfl_cap_is_smartphone|$wurfl_cap_is_tablet $backend_pool_name {
true|false "SmartphonePool";
false|true "TabletPool";
# any other combination will redirect to GeneralPurposePool
default "GeneralPurposePool";

server {
listen 80;
server_name localhost;

location / {
# hredirect request to the target upstream
proxy_pass http://$backend_pool_name;

Note that the IP addresses and upstream block names are examples only. Change them to match your test environment.

To start a free 30-day trial of the WURFL InFuze NGINX Plus Certified Module, visit ScientiaMobile.

To try NGINX Plus, start your free 30-day trial today or contact us for a demo.

Cover image
Free O'Reilly Ebook
Your guide to everything NGINX