[1] 정상

server {
        listen 10000 ;
        listen [::]:10000 ;

        server_name ngtest.koreaats.com;

        location ~ /aa {
            return 302 http://$server_name:8000;
        }

        location ~ /bb {
            return 302 http://$server_name:9000;
        }
}

[2] 의도하지 않음

server {
        listen 10000 ;
        listen [::]:10000 ;

        server_name _;

        location ~ /aa {
            return 302 <http://localhost:8000>;
        }

        location ~ /bb {
            return 302 <http://localhost:9000>;
        }
}

[3] 안됨

server {
    listen 9999;

    location /api {
        proxy_pass <http://localhost:13001>;
    }

    location /dev {
        proxy_pass <http://localhost:18001>;
    }
}

[4] 정상(의도한 동작)

server {
    listen 9999;

    location /dev0 {
        proxy_pass <http://localhost:18001/>;
    }

    location /dev1 {
        proxy_pass <http://localhost:19001/>;
    }
}