Nginx – How to check nginx root folder

debiannginx

I have a very basic 404 error:

Description: HTTP 404.The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make sure
that it is spelled correctly.

Details: Requested URL: /index.html

I cannot figure out which full url is finally called.

My index.html is very basic :

<html><body>hello</body></html>

My config file :

server {

 listen 8045;

        server_name localhost;
        root /usr/share/nginx/asproot;

        access_log /var/log/nginx/asp.access.log;

        error_log /var/log/nginx/asp.error.log;

location / {

        index index.html index.htm default.aspx Default.aspx;

        fastcgi_index Default.aspx;

        fastcgi_pass 127.0.0.1:9000;

        include /etc/nginx/fastcgi_params;

     }

 }

The nginx user can access the root folder and read index.html (I tested this with su).
In the browser I load: http://serverip:8045/index.html

So what is going wrong?
How can I see what the final url is called?


EDIT

I figured out that problem comes from fastcgi. I've read several articles but i'm lost !

To avoid a long question with huge historic, i abort this and i'll post a new question once i'll have understood the basics of fastcgi with nginx. Anyway i give a config that finally works (see few answers below)

Best Answer

It seems that when you access the root directory, "index" directive gets applied, but when you are accessing directly, it applies the "fastcgi_pass" directive. You should probably check before the pass directive if the file is even present.

Seems like I have a similar need as yours, I use this config for it:

server {
    listen      80;
    server_name localhost;

    # PublicRoot
    root /usr/share/nginx/asproot;

    # Logs
    access_log /var/log/nginx/asp.access.log main buffer=50k;
    error_log /var/log/nginx/asp.error.log;

    location / {
        try_files $uri @fastcgi;
    }

    # Fastcgi-pass
    location @fastcgi {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_keep_conn on;
        include /etc/nginx/fastcgi_params;
        fastcgi_intercept_errors on;
    }


}

Here I first go by "try_files" directive to check if I can get the static file, but if not, I go then by the fastcgi_pass directive. But I'm hosting the aspx files in different folder, not the same with static files.