Site Reliability Team Lead at News UK

View My GitHub Profile

25 November 2011

Nginx Virtual Host Ordering

by Mike

Just a quick note.

Nginx will include configuration files based on lexical ordering. This means that even if you have two files default (with the default config) and cloud, cloud will be included before default and will answer for any undefined hostnames unless you specify the default_server directive.

The easy way to solve this (and obvious if you have been around Linux for a while) is to prefix all config files with a number. For example:


This will result in 00-default being included in the configuration first.

I hope this is useful for someone out there.