How to use server_name with stream NGINX?

server_name is used to specify HTTP virtual host name for a server block.

stream module is a TCP stream proxy module, and TCP streams have no concepts of virtual host names.

So, the answer is that you cannot use server_name with stream module.