user2025329
user2025329

Reputation: 187

Default nginx conf file

Suppose I have 3 nginx conf files and default_server is not defined in any of them. Now if a request comes to the serve and If its value does not match any server name, or the request does not contain that header field, It will take which nginx config to serve the request.

I mean how is it prioritized?

Upvotes: 0

Views: 2065

Answers (2)

hostmaster
hostmaster

Reputation: 2150

Please take a look at nginx documentation Server names

If no server_name is defined in a server block then nginx uses the empty name as the server name.

nginx versions up to 0.8.48 used the machine’s hostname as the 
server name in this case

Upvotes: 0

stranger
stranger

Reputation: 31

I guess, first vhost would be used. If you use including virtual hosts (/etc/nginx/sites-enabled/*) the hosts would be included in alphabetical order. So, if you have hosts "a", "b" and "c", first of them will be "a".

Upvotes: 1

Related Questions