Web Server Load Balancing with NGINX Plus

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 Certified Module for NGINX Plus, 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 NGINX Open Source 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 NGINX Open Source 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/;

worker_processes 1;

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

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/;

    # 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 to discuss your use cases.

Hero image
免费 O'Reilly 电子书:
《NGINX 完全指南》

更新于 2022 年,一本书了解关于 NGINX 的一切


Ken Jones

VP of Marketing


F5, Inc. 是备受欢迎的开源软件 NGINX 背后的商业公司。我们为现代应用的开发和交付提供一整套技术。我们的联合解决方案弥合了 NetOps 和 DevOps 之间的横沟,提供从代码到用户的多云应用服务。访问 了解更多相关信息。