Welcome! Log In Create A New Profile

Advanced

setting server_name = hostname explicitly

January 17, 2011 02:24PM
Hi everyone,

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,
Seth
Subject Author Posted

setting server_name = hostname explicitly

spurcell January 17, 2011 02:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 105
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready