<div dir="ltr">TCP has no concept of server names, so this is not possible. It only works in HTTP because the client sends the hostname it is trying to access as part of the request, allowing nginx to match it to a specific server block.<div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 2, 2015 at 12:31 PM, Charles Nnamdi Akalugwu <span dir="ltr"><<a href="mailto:cprenzberg@gmail.com" target="_blank">cprenzberg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:12.8px">Hi guys,</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I have the following tcp server block in my nginx.conf</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div>stream {</div><div> upstream kafka_producer {</div><div><br></div><div> server kafka.service.consul:9092;</div><div> }</div><div><br></div><div> server {</div><div> listen 9092;</div><div> server_name <a href="http://kafka.stream.mycompany.com/" target="_blank">kafka.stream.mycompany.com</a>;</div><div> proxy_connect_timeout 10s;</div><div> proxy_timeout 30s;</div><div> proxy_pass kafka_producer;</div><div> }</div><div>}</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I would like that my kafka tcp stream is accessible using only the <a href="http://kafka.stream.mycompany.com:9092/" target="_blank">kafka.stream.mycompany.com:9092</a> address....just in the same way that it works with http server blocks.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">However I get the following error regarding the server_name: </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><b>"server_name" directive is not allowed here in /etc/nginx/nginx.conf</b><br></div><div style="font-size:12.8px"><b><br></b></div><div style="font-size:12.8px">So who knows how I can simulate server_name within tcp server blocks?</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks!</div></div>
<br>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br></div></div>