location / {

    if ($arg_public_id ~* ^%s$) {
        proxy_pass http://127.0.0.1:%s;
    }
