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_portnnTime: $time_localnn";
}

server {
    listen 8082;
    return 200 "Mobile 📱 backend $server_addr:$server_portnnTime: $time_localnn";
}

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
免费 O'Reilly 电子书:
《NGINX 完全指南》

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

关于作者

Nick Shadrin

Software Architect

关于 F5 NGINX

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