Welcome! Log In Create A New Profile

Advanced

Re: try_files

Maxim Dounin
May 20, 2011 08:14AM
Hello!

On Fri, May 20, 2011 at 06:57:23AM -0400, David J. wrote:

> Running Nginx v1.0.0
>
> Here is server config
>
> server {
> listen 80;
> server_name domain.com www.domain.com;
> location /{
> index index.html index index.htm index.php;
> root /www/domain.com;
> try_files $uri $uri/ @wsgi;
> }
>
> location @wsgi {
> index index.html index.htm;
> include uwsgi_params;
>
> uwsgi_pass unix:/tmp/uwsgi.sock;
> }
> location ~ \.css$ {
> root /www/domain.com;
> }
>
> }

It doesn't looks like you have "index" directive set to
"index.wsgi" nor any actual handling of index.wsgi (except
try_files fallback). This all makes me think that you actually
don't have index.wsgi on filesystem either.

Note that "index" directive will actually test existence of given
index files on filesystem and will do an internal redirect if one
was found. That is, if you don't have any index files on
filesystem - you'll get 403 (unless autoindex module enabled).

The configuration you probably want is something like

root /www/domain.com;

location / {
try_files $uri $uri/index.html @wsgi;
}

location @wsgi {
uwsgi_pass ...
}

That is: if file exists, return it; if there is a directory with
index.html, return it; else fallback to wsgi.

Maxim Dounin

>
>
> On 5/20/11 6:23 AM, Maxim Dounin wrote:
> >Hello!
> >
> >On Thu, May 19, 2011 at 06:10:04PM -0400, David J. wrote:
> >
> >>I have a uwsgi_app
> >>
> >>I was wondering why
> >>
> >>location / {
> >>root /myapp;
> >>index index.html index.wsgi;
> >>try_files $uri $uri/ @wsgi;
> >>}
> >>;
> >>
> >>When I visit the domain.com returns a 403 (when I dont have an
> >>index.html file in the root directory);
> >>
> >>but if I do domain.com/index.wsgi
> >>
> >>The WSGI app is called. This all works.
> >>
> >>I am guessing I am doing something wrong.
> >>
> >>In my config I have
> >>
> >>location @wsgi {
> >> include uwsgi_params;
> >> uwsgi_pass unix:/tmp/uwsgi.sock
> >>}
> >Please show full config.
> >
> >Maxim Dounin
> >
> >_______________________________________________
> >nginx mailing list
> >nginx@nginx.org
> >http://nginx.org/mailman/listinfo/nginx
> >
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

try_files

David J. May 19, 2011 06:10PM

Re: try_files

Maxim Dounin May 20, 2011 06:24AM

Re: try_files

David J. May 20, 2011 06:58AM

Re: try_files

Maxim Dounin May 20, 2011 08:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 172
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready