Very wierd config error..

kolbyjack nginx-forum at nginx.us
Fri Apr 13 12:23:06 UTC 2012


Maxim Dounin Wrote:
-------------------------------------------------------
> Hello!
> 
> On Fri, Apr 13, 2012 at 07:02:45AM -0400,
> alexscott wrote:
> 
> > Hello!
> > I'm sorry to bother the forum with these kind of
> questions, but I simply
> > can't figure out what I'm doing wrong here:
> > 
> > When I access sub.domain.net/ I still get the
> 502 error instead of being
> > served from the /somefolder/stuff folder?....
> > 
> > server {
> > 	listen 80;
> > 	server_name sub.domain.net;
> > 
> > location = / {
> > root /somefolder/stuff;
> > index index.html index.htm;
> > 
> > }
> > 
> > location / {
> > 
> > return 502;
> > 
> > }
> > 
> > }
> 
> Detailed explanation is given here:
> http://nginx.org/en/docs/http/request_processing.h
> tml#simple_php_site_configuration
> 
> In short: request to "/" is internally redirected
> to 
> "/index.html", and then handled in "location /". 
> Try this 
> instead:
> 
>     root /somefolder/stuff;
> 
>     location = / {
>         index index.html index.htm;
>     }
> 
>     location = /index.html {
>         internal;
>     }
> 
>     location = /index.htm {
>         internal;
>     }
> 
>     location / {
>         return 502;
>     }
> 
> Maxim Dounin
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

You can also do this without adding new locations by using try_files
instead of index.

root /somefolder/stuff;

location = / {
  try_files /index.html /index.htm =404;
}

location / {
  return 502;
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,225300,225305#msg-225305



More information about the nginx mailing list