Random order of configuration file reading

Joshua Zhu zhuzhaoyuan at gmail.com
Wed Nov 28 11:48:27 UTC 2012


On Tue, Nov 27, 2012 at 10:07 PM, philipp <nginx-forum at nginx.us> wrote:

> Hello,
> we have a bunch of servers which are configured 100% equal expect of host
> specific settings like ip address in the listener using chef/puppet. Nginx
> seems to read include / config files not in the same order on each server.
> For example we haven't defined a default vhost on each server... so nginx
> uses the first loaded file which is exampleA.com on server 1 and
> exampleB.com on server 2.
> Furhtermore we use the upstream check status module, the status page is
> randomly ordered at each server...
> Is it possible to configure nginx to read config in the alphabeticial
> order?
> For example
> vhosts/exampleA.com (1.)
> vhosts/exampleB.com (2.)

This is a known issue. It has been fixed in our own

If you want to use official nginx only, you can apply the patch below:

Would you please consider to apply this patch to the trunk? Thanks in

Index: src/os/unix/ngx_files.c
--- src/os/unix/ngx_files.c     (revision 4942)
+++ src/os/unix/ngx_files.c     (working copy)
@@ -363,7 +363,7 @@
     int  n;

-    n = glob((char *) gl->pattern, GLOB_NOSORT, NULL, &gl->pglob);
+    n = glob((char *) gl->pattern, 0, NULL, &gl->pglob);

     if (n == 0) {
         return NGX_OK;


Joshua Zhu
Senior Software Engineer
Server Platforms Team at Taobao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20121128/86d62e2b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: include-sorted.patch
Type: application/octet-stream
Size: 395 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20121128/86d62e2b/attachment.obj>

More information about the nginx mailing list