Directory Listing: 403 Forbidden Nginx

Asked

Viewed 541 times

1

I need help, I started using Nginx now, I was researching about then I decided to test it, and I don’t know how to configure it properly, but I wanted to enable directory search. In his documentation it is (AutoIndex: on) but I use this, it does not appear, of error 403. Nginx is in C:/, but I set it to be directed in my folder C:/projetos. If anyone knows how I can fix it.

Code setting of it:

worker_processes  1;

    events {
        worker_connections  1024;
    }

    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;


        server {
            listen 80;
            server_name localhost;

            root C:\Project ;
            index index.html index.htm index.php;

            location / {
                autoindex on;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    }
  • Good afternoon, managed to solve the problem?

  • 1

    Good morning, I managed yes, it was very simple, the folder path was incorrect.

1 answer

0

Instead of root C:\Project ; use like this root C:/Project;, recommend using inside location / { (as it is in the default configuration). It looks like you’re trying to set it up with PHP, note that we usually use fastcgi, an example (read the comments followed by # if you have any doubts regarding the use):

worker_processes  1;

# Gera logs de erro
error_log  logs/error.log;
error_log  logs/error.log  notice;
error_log  logs/error.log  info;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   C:/Project;
            index  index.html index.htm;
            autoindex on;
        }

        error_page  404              /404.html;

        # redireciona páginas de erro para páginas estaticas /50x.html (no root)
        error_page   500 502 503 504  /50x.html;

        location = /50x.html {
            root   html;
        }

        # Configura o php
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;

            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $request_filename;
            include        fastcgi_params;
        }
    }
}
  • Didn’t work, need to have some index file inside the directory? because I just wanted to browse among the folders, like Apache, like this: http://www.nacaolivre.com.br/wp-content/uploads/2010/10/list-directory-apache.jpg

  • is agree with you sorry, continues on the same error "403 Forbidden".

  • I think so, when I access the log, it informs me permission error, you know how I fix it ?

  • Same mistake 403, I think I’ll have to dig deeper into this case

  • @Guilhermealmeida The user running Ngnix has some "block", are you running it as an administrator? Which folder Ngnix is installed in?

  • I’m running it as an administrator, it’s in the C:/Ngnix folder

  • @Guilhermealmeida c:/nginx? Which version?

  • Nginx version 1.9.2

  • Try something first, move the projectc folder and ngnix folder to a folder called wnmp, for example: c:\wnmp\nginx and c:\wnmp\project and edit the ngnix.conf files and try to run the server again. If the problem persists, please restart windows and try again. @Guilhermealmeida

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.