user  nginx;
worker_processes  auto;

load_module /usr/lib/nginx/modules/ngx_stream_module.so;

error_log  /logs/upstream_error;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

stream {
    upstream other {
        server ng:443;
    }

    upstream reality {
        server xr:443;
    }

    upstream ocserv {
        server oc:443;
    }

    upstream naive {
        server np:443;
    }

    map_hash_bucket_size 128;
    map $ssl_preread_server_name $sni_name {
        #domain
        www.microsoft.com reality;
        #domain

        #ocserv
        #oc.domain ocserv;
        #ocserv

        #naive
        #np.domain naive;
        #naive
        default other;
    }

    server {
        listen          443 reuseport;
        proxy_pass      $sni_name;
        proxy_protocol  on;
        ssl_preread     on;
    }

    server {
        listen          443 udp;
        proxy_pass      $sni_name;
        proxy_protocol  on;
        ssl_preread     on;
    }
}
