8

When nginx serves a directory with autoindex, it will list files, but when index.html exists, the browser will load that file. I want it to ignore it.

server {
    listen      80;
    server_name herbert;

    location / {
        root /srv/www;
        index index.htm index.html;
        add_header Cache-Control no-cache;
        expires 300s;
    }

    location /site-dumps/ {

        root /srv/www/;
        autoindex on;
    }
}
caduceus
  • 1,542
  • 2
  • 16
  • 21

3 Answers3

2

It's not possible. You should move other files in other directory and create an iframe in index.html.

Something like that:

index.html

<iframe src="/site-dumps_files"></iframe>

nginx.cnf

server {
      listen      80;
      server_name herbert;

      location / {
        root /srv/www;
        index index.htm index.html;
        add_header Cache-Control no-cache;
        expires 300s;
      }

      location /site-dumps/ {
        root /srv/www/;
      }

      location /site-dumps_files/ {
        root /srv/www/;
        autoindex on;
      }
}

I hope it useful for you.

AS Mackay
  • 2,831
  • 9
  • 19
  • 25
Sandra
  • 358
  • 3
  • 5
0

this worked for me:

server {
 listen 80;
 listen [::]:80;

 server_name localhost;

 autoindex on;
 index =404;
 
 location / {
   root /path_to_www_dir;
 }
}
guest
  • 1
-1

Put: index main.html main.htm; instead of index index.htm index.html;

Zakwan
  • 1,072
  • 2
  • 11
  • 22