problem with / location stanza

Maxim Dounin mdounin at mdounin.ru
Thu Apr 14 02:37:28 MSD 2011


Hello!

On Wed, Apr 13, 2011 at 03:06:04PM -0700, Michael Barrett wrote:

> I'm trying to make it so that if I get a request to / on my host 
> to any hostname that doesn't start with 'www' it will check for 
> a static page on the server, and if that doesn't exist it goes 
> back to my uwsgi process for dynamic content.  So basically:
> 
> http://www.example.com/ - Goes to the uwsgi process
> http://foo.example.com/ - Checks for a static file 
> (/landing-cache/vanity:foo.html), if it can't find it it goes to 
> the uwsgi process
> http://foo.example.com/bar/ - Is dealt with in other location 
> stanzas.
> 
> Anyway, here's the location stanza I'm trying to use:
> 
>     location = / {
>         if ($host ~ ^([^.]+)\.) {
>             set $hn $1;
>         }
> 
>         if ($hn !~ ^www\.) {
>             set $vanity $hn;
>         }
> 
>         try_files /landing-cache/vanity:$vanity.html 
>         @ebdjango_uwsgi;
>     }
> 
> For some reason, whenever I have this in my config I get the 
> following error when I try to hit http://foo.example.com/:
> 
> Apr 13 14:53:01 stage-djcore-www1 nginx: 2011/04/13 14:53:01 
> [error] 23919#0: *3227 directory index of 
> "/usr/local/www/eventbrite/releases/current/python/" is 
> forbidden, client: 127.0.0.1, server: , request: "GET / 
> HTTP/1.1", host: "foo.example.com"
> 
> If I don't have that in my config, then this stanza is hit, and 
> it sends everything back to my uwsgi server:
> 
>     location / {
>         uwsgi_pass ebdjango_uwsgi;
>     }
> 
> Anyone have any idea why this might be?  Thanks in advance for 
> your help, I'm banging my head against the table.

http://wiki.nginx.org/IfIsEvil

Maxim Dounin



More information about the nginx mailing list