Based on the nginx wiki the $hostname variable is "Set to the machine's hostname as returned by gethostname ". I tried that and although gethostname doesn't work my debian box it still returns the host correctly. Then I tried to use that variable $hostname to set the server_name, but that didn't work. Why is that and is there another way I can accomplish that.
server {
listen 80;
autoindex off;
server_name static.$hostname;
root /var/www/static;
access_log /var/log/nginx/localhost.access.log;
location / {
index index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
}