Home > nginx > How to check nginx root folder

How to check nginx root folder

August 18Hits:1

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 :


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;          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?


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)


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_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.

ok i finnaly made it working. I still have an other problem, index doesn't works So i have to type the full address :


if i just type :

http://localhost:8045 or http://localhost:8045/default.aspx

then i have a 404 error (so url is case sensitive)

As i said now fastcgi works, things still obscure and i have to improve it. Anyway, i give you all my config , i hope this will help someone:

OS : rapbian 3.18.11 (debian) Mono : 4.0.2 fastcgi-server4 nginx 1.2.1


config file :


commandline :


MONOSERVER=$(which fastcgi-mono-server4)

${MONOSERVER} /appconfigdir=${CONFIG_PATH} /socket=tcp: /logfile=${LOG} --verbose &



fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;

fastcgi_param   SCRIPT_FILENAME         $request_filename;
fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;

fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;

fastcgi_param   HTTPS                   $https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;
fastcgi_param PATH_INFO "";

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

site-avalaible/default (i made so many tries, here what it is now) :

server {

 listen 8045;

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

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

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

location ~ \.(aspx|asmx|ashx|asax|ascx|soap|rem|axd|cs|config|dll)$ {
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
        fastcgi_intercept_errors on;


location / {
        root html;
        index index.html index.htm default.aspx Default.aspx;


Web Content : /usr/share/nginx/asproot/web.config :



<customErrors mode="Off"/>




<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <% var test = String.Format("Hello World! Got an aspx page running on nginx!!!\r\n{0}",System.DateTime.Now); %>

    <%= test %>


Tags:debian, nginx

Related Articles

  • How to check nginx root folderAugust 18

    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

  • Domain points to nginx root folder instead of /var/www/mydomain/webSeptember 3

    After adding and configuring domain in ISPconfig it shows the files from Code: /usr/share/nginx/html/ instead of Code: /var/www/mydomain/web What can be the reason of such issue? Any advice or reference about this would be greate, Thank you! --------

  • Does Wordpress check for updates of a plugin via plugins root folder name?June 5

    I just completed writing a plugin from another plugin. When I changed the developer name, version and other details from the plugin file, I thought the version tracing would now be done using the new name of the plugin but it actually linked the upda

  • How Do I check Permissions of Root Folder (/ Folder, not /root)?March 25

    Is there a way to check the permissions of the root folder, /? I mean the folder's permissions, not its content's (/var, /usr, etc.) permissions? Running ls /.. shows the content's permissions. --------------Solutions------------- You can also use th

  • why does nginx sets root folder to wrong location?January 18

    I want to have two servers on my machine, one private, accessible only locally on and one which is visible on LAN (it's root folder is subfolder of the private server). So I have made two configuration files in sites-available and linked th

  • nginx how to serve 'admin' subdomain request fro a specific root folder?February 6

    Is it possible to serve all requests to example.com ( and www.example.co) from the root folder location / { root html; index index.html index.htm; } but all requests to admin.example.com from a another folder 'admin' on the same server ? ------------

  • Double root folder vs single root folderSeptember 14

    On my Linux box, in bash, I have access to a "double root" folder denoted by two forward slashes: tomas:~ $ cd / tomas:/ $ ls bin/ cdrom@ ... tomas:/ $ cd // tomas:// $ ls bin/ cdrom@ ... The content of the folder and its subfolder is identical

  • Map files in sub directory to root folder via .htaccessOctober 27

    I have a large number of files in a sub directory. I would like to map these files to the root directory such that the request for "http://www.mysite.com/filename" actually points to "http://www.mysite.com/subfolder/filename.php" on th

  • Creating files in NTFS root folderNovember 30

    Introduction: I'm attempting (and in part succeding) in replacing a number of folders with mounted VHDs in Windows Server 2008 R2, in an attempt to emulate UNIX' bahaviour with bind- or loop-mounts. This has proven to reduce a number of problems rela

  • cannot write to nginx www folderApril 29

    I've recently installed nginx on my dev machine with Ubuntu 12.04. I am currently logged in as myuser and after installing nginx I setup the following file permissions (nginx www folder was owned by root so I wanted to change that so I can edit files

  • I Can't access the root folderSeptember 15

    I do not have access to my root folder: Ubuntu says I do not have the necessary permissions to access it. I also cannot access lost + found, which gives me the same error message Is there anyone here that can provide answers to these questions? -----

  • Recover, reconstruct, rebuild files after NTFS laptop disk crash - root folder and MFT destroyedOctober 20

    My 120GB laptop disk has crashed and is no longer bootable nor readable by Windows. I was running Windows XP Pro SP3 on it (sole partition). To save embarrassment let's just say that my last backup was more than one week old! (...and I am planning a

  • Is copying the root folder an adequate form of backup?March 9

    I am working in a small organization with about 8 or so Linux independent servers. While we currently do remote backups among the machines, I was told to make an "emergency backup" of the machines to an external drive. Here is my current plan: M

  • SVN - rename root folderAugust 5

    To rename a folder in a working copy, we can run svn mv. But when you try to rename the root folder, you end up with svn: E155007: '/home/username/svn_repos' is not a working copy Where 'svn_repos' is where I'm storing all my individual repositories

  • cd .. on root folderApril 22

    Why cd .., typed at root folder, does not warn or fails with an error? I would expect: /$ cd .. -bash: cd: ..: No such file or directory Instead, I'm left at /. Of course, this is since .. does exist in /, and is simply /, just like .. I just wonder

  • How to access root folder?April 26

    I just did a data recovery of a very important file, and it is saved in root folder automatically, and I can't access root folder even from gksu nautilus it gives this dialog: You do not have the permissions necessary to view the contents of "root&qu

  • Duplicate file ~ in root folder July 7

    This question already has an answer here: Prevent gedit from creating files with the '~' (tilde) suffix 7 answers I have a copy of all the files in my root folder with ~ symbol. I can see it on the terminal but not in the folder. How do i stop this -

  • How to add windows media player context menu to library root folder

    How to add windows media player context menu to library root folderSeptember 5

    How can I add windows media player options to my music library root folder's context menu? I have VLC player and MP3tag installed which DO have options on context menu but windows media player is missing. The folder is already optimised for music in

  • how to disable folders/files under root folder in RHEL?April 2

    I want to "disable" listing of folders and files under root folder in RHEL. So when I login to my application nothing should be visible in root folder. --------------Solutions------------- Since you want to disable your application to see anythi

  • Nginx redirect folder to subdomainJune 5

    I'm trying to configure a redirect on Nginx from a folder to a subdomain. I've tried already Nginx redirect: folder to external domain and Nginx rewrite rule (subdirectory to subdomain) and nginx: redirect subfolder to subdomain. Nothing works. The p

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.480 s.