To make a long story short, the most efficient way of doing this is simply to change the document root according to the sub domain
So within your server stanza, you can simply do the following
server_name ~^(?.+)\.tech-g\.com$; root /var/www_nginx/$sub;
This way, when you add a directory such as myothersite.com inside your nginx web directory, visitors comming to myothersite.com.tech-g.com will end up being served content from the directory /var/www_nginx/myothersite.com
No rewriting URLs needed, and no evil if statements either