map $room $room_server {
    default 192.168.1.101:8080;
    1 192.168.1.101:8080;
    2 192.168.1.102:8080;
}

server {
    listen  80;

    location ~ /api/(\d+)/room {
        set $room $1;
        echo $room_server;
    }
}

split_clients 类似的结构,可以用来做请求 A/B 测试:

split_clients $arg_app_key $variant {
    0.5%    .one;
    2.0%    .two;
    *       "";
}

nginx mirroring tips and tricks