If Igor’s reading, I just want to say that NGINX is amazing and we love
it. Thank you!
Apologies if this has already been answered elsewhere, but I spent a lot
of time looking and couldn’t find a solution: is there any way to
specify the current hostname as a valid server_name explicitly without
using a literal? I know this is what you get if you just leave
server_name unspecified, but then I can’t also have it match
“localhost”, without it being the default server.
So I guess my question could be rephrased as: how can I set up a server
to match requests to “localhost” and whatever the machine’s hostname is
without hard-coding the hostname in the config file or making the server
the default. (I don’t want the server to be the “default” server for
port 80; I want another server to do that.)
server_name $hostname; doesn’t appear to work, and neither does
server_name ~$hostname; and I’d like to avoid regex processing overhead
anyway. I guess ideally what I’d like would be:
server_name $hostname localhost;
or something like that. And if neither matched, it would fall through to
the default server.
Thanks and sorry if I’m just being obtuse,
Posted at Nginx Forum: