Not opening default site page via FastCGI and try_files

Hi,

I use FastCGI and try_files with Nginx.

FastCGI catches all url patterns and render appropriate page.

It works well for urls like
site.com/some-page
site.com/index.htm
site.com/any-page.htm
site.com/any-wildcarded-page-name-at-all

But it never works for site root
site.com/

I use try_files.
Can you point me how to make default site URL work?

This is my Nginx conf:

server_name_in_redirect off;
listen 80;
server_name ~^(www.)?(.+)$;
root /var/www/$2/htdocs;

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

location @django {
fastcgi_pass 127.0.0.1:8801;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
fastcgi_param REMOTE_ADDR $remote_addr;
}

Thanks.

On Fri, Sep 04, 2009 at 01:46:01PM +0200, Ale Ru wrote:

site.com/any-wildcarded-page-name-at-all
listen 80;
server_name ~^(www.)?(.+)$;
root /var/www/$2/htdocs;

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

Try

location / {
try_files $uri $uri/index.htm @django;
}

or

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

Igor S. wrote:

On Fri, Sep 04, 2009 at 01:46:01PM +0200, Ale Ru wrote:

site.com/any-wildcarded-page-name-at-all
listen 80;
server_name ~^(www.)?(.+)$;
root /var/www/$2/htdocs;

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

Try

location / {
try_files $uri $uri/index.htm @django;
}

or

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

This is what i have in nginx.conf. It works for all files except site
root page.
What is the difference from my original config? i tried both changes
(delted $uri/ or delted $uri/index.htm) - the same effect.

when i type domain.com/index.htm (and there are no static index.htm
page) i get the page from django FCGI script

when i type domain.com/ (and there is a static page called index.htm)
i get static page

but when i type domain.com/ (and there is no static page called
index.htm) i get
403 Forbidden
nginx/0.7.61

On Fri, Sep 04, 2009 at 02:31:51PM +0200, Ale Ru wrote:

   index index.html index.htm;

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

This is what i have in nginx.conf. It works for all files except site
root page.
What is the difference from my original config? i tried both changes
(delted $uri/ or delted $uri/index.htm) - the same effect.

The difference is only in order of file existance testing.

when i type domain.com/index.htm (and there are no static index.htm
page) i get the page from django FCGI script

when i type domain.com/ (and there is a static page called index.htm)
i get static page

but when i type domain.com/ (and there is no static page called
index.htm) i get
403 Forbidden
nginx/0.7.61

Then you need

location @dajno {
fastcgi_index index.htm;

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs