worker_processes auto;
events { worker_connections 2048; }

stream {
    map $ssl_preread_server_name $backend {
        turns.example.test  coturn;
        default             caddy;
    }

    upstream caddy  { server caddy.internal:8443; }
    upstream coturn { server coturn.internal:5349; }

    server {
        listen 443;
        ssl_preread on;
        proxy_pass $backend;
        proxy_connect_timeout 5s;
        proxy_timeout 300s;
    }
}
