NGINX.COM
Web Server Load Balancing with NGINX Plus

Here at NGINX we strive to support the latest technologies, development best practices, and DevOps principles.

It is well known that the use of emoji has grown significantly in the last several years. Most Internet users utilize them in place of standard emoticons and many individuals can now have full, meaningful conversations without using any conventional ASCII letters.

NGINX has become the most appealing web server for the latest generation of developers, and the recent announcement of support for JavaScript in NGINX configuration files has increased our usage among these young, up-and-coming technologists. To increase our appeal to the younger generation of DevOps and web developers, we are introducing full support for emoji in NGINX configuration files.

You can now use emoji in the comments, variable values, regular expressions, and even the names of objects.

Here are some examples.

Instead of “color-coding” your server objects, you can emoji-code them with comments:

upstream backend {
    zone backend 64k;
    server backend1.example.com;         # 😀 
    server backend2.example.com backup;  # 😁 
    server backend3.example.com down;    # 😡 
}

If you are using NGINX Plus, you can configure route-based session persistence with emoji route names:

upstream backend {
    zone backend 64k;
    server 127.0.0.1:8081  route="😂😂"; 
    server 127.0.0.1:8082  route="👍👍"; 
}

You can specify upstream names that better characterize the purpose of the upstream. The example shows a method for sending 📱 clients to mobile upstream servers and 💻 clients to the default upstream group:

upstream 📱 { 
    zone 📱 64k;
    server 127.0.0.1:8081;
}

upstream 💻 { 
    zone 💻 64k;
    server 127.0.0.1:8082;
}

map $http_user_agent $upstreamname {
    default           💻;
    ~(iPhone|Android) 📱;
}

server {
    listen 8081;
    return 200 "Desktop 💻 backend $server_addr:$server_port\n\nTime: $time_local\n\n";
}

server {
    listen 8082;
    return 200 "Mobile 📱 backend $server_addr:$server_port\n\nTime: $time_local\n\n";
}

server {
    location / {
        proxy_pass http://$upstreamname;
    }
}

You can block unwanted IP addresses using GeoIP functionality and set the variable in a visual manner:

geo $remote_addr $👀 { 
    10.2.3.4  💩; 
    default   😃; 
}
server {
     location / {
        if ($👀 = 💩) {
            return 403 "Access denied! ✋❗\n"; 
        }
        proxy_pass http://💻;
    }
}

You can download all of these examples in a sample NGINX Plus configuration file. To get started with emoji configuration in your own NGINX Plus environment, start your free 30-day trial today or contact us to discuss your use cases (please include 🙏 in the Inquiry details box).

Hero image
Free O'Reilly eBook: The Complete NGINX Cookbook

Updated for 2024 – Your guide to everything NGINX



About The Author

Nick Shadrin

Software Architect

About F5 NGINX

F5, Inc. is the company behind NGINX, the popular open source project. We offer a suite of technologies for developing and delivering modern applications. Together with F5, our combined solution bridges the gap between NetOps and DevOps, with multi-cloud application services that span from code to customer.

Learn more at nginx.com or join the conversation by following @nginx on Twitter.