4 messages in ru.sysoev.nginxRe: Working with include directive an...
FromSent OnAttachments
Ian SeffermanJun 28, 2008 7:43 pm 
Igor SysoevJun 29, 2008 12:42 am 
mikeJun 29, 2008 2:13 am 
Igor SysoevJun 29, 2008 6:32 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Working with include directive and wildcards?Actions...
From:Igor Sysoev (is-G@public.gmane.org)
Date:Jun 29, 2008 12:42:42 am
List:ru.sysoev.nginx

On Sat, Jun 28, 2008 at 07:43:35PM -0700, Ian Sefferman wrote:

I'm trying to figure out an issue with the include directive and wildcards in v0.5.33 (on Ubuntu Hardy).

My nginx.conf file looks like so (trimmed):

http { include /u/apps/*/current/config/nginx.conf; }

Then, I have two directories within /u/apps, each with their own config: /u/apps/bar/current/config/nginx.conf (trimmed): server { listen 80; server_name _ *; location / { proxy_pass http://bar_mongrel; } }

/u/apps/foo/current/config/nginx.conf (trimmed): server { listen 80; server_name foo.domain.com; location { proxy_pass http://foo_mongrel; } }

This code never reaches the bar server, it only ever returns foo. However, when I change my nginx.conf to: http { include /u/apps/bar/current/config/nginx.conf; include /u/apps/foo/current/config/nginx.conf; }

... it works perfectly (and I change the order of those two and it still works fine).

I'm wondering what I'm doing wrong here?

Wildcard includes are not sorted. Thus, probably, bar was included after foo. "server_name ... *" is not default server, it's ugly hack, and it had been removed in 0.6.x. The default server was alwayes set in listen directive:

listen 80 default;

If you do not set it explicitly, it will be first server. So:

- listen 80; - server_name _ *; + listen 80 default; + server_name _;