I want to have NGINX do an auto index of a directory (\var\www\HTML\archive). This on a raspberry pi.
Here is the NGINX.conf bit relating to users, servers, and locations
#user www-data;
#user nginx;
user pi;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
...
server{
listen 80;
root /var/www/html;
index index.html;
location /archive/ {
root /var/www/html;
index index.html;
autoindex on;
}
}
By the way, I tried all different users - including root!
In the error log I have:
2018/06/08 23:35:07 [error] 22477#22477: *2 directory index of "/var/www/html/archive/" is forbidden, client: 10.0.0.6, server: _, request: "GET /archive/ HTTP/1.1", host: "10.0.0.16"
But I did all the chmod g+s, chmod 644 for files etc.
pi@fridge-monitor:/var/www/html $ ls -al
total 24
drwxrwsr-x 4 root nginx 4096 Jun 8 11:57 .
drwxrwsr-x 3 root nginx 4096 Jun 2 18:41 ..
drwxr-sr-x 2 pi nginx 4096 Jun 8 12:59 archive
drwxr-sr-x 2 pi nginx 4096 Jun 8 10:53 dynamic
-rw-r--r-- 1 pi nginx 2653 Jun 8 10:50 index.html
pi@fridge-monitor:/var/www/html $ ls -al archive
total 168
drwxr-sr-x 2 pi nginx 4096 Jun 8 12:59 .
drwxrwsr-x 4 root nginx 4096 Jun 8 11:57 ..
-rw-r--r-- 1 pi nginx 38113 Jun 8 12:41 1d.png
-rw-r--r-- 1 pi nginx 366 Jun 8 12:41 table.html
I believe that the upper directories are OK as well:
pi@fridge-monitor:/var/www/html $ namei -l /var/www/html/archive
f: /var/www/html/archive
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxrwsr-x root nginx www
drwxrwsr-x root nginx html
drwxr-sr-x pi nginx archive
I can see the files in /archive/ for example if I go 10.0.0.16/archive/1d.png then the graphic is displayed.
Having followed some steps in other posts:
[pid 4222] stat64("/var/www/html/archive/", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
[pid 4222] stat64("/var/www/html/archive/", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
[pid 4222] stat64("/var/www/html/archive/index.html", 0x7efe1750) = -1 ENOENT (No such file or directory)
[pid 4222] stat64("/var/www/html/archive", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
[pid 4222] stat64("/var/www/html/archive/index.htm", 0x7efe1750) = -1 ENOENT (No such file or directory)
[pid 4222] stat64("/var/www/html/archive/index.nginx-debian.html", 0x7efe1750) = -1 ENOENT (No such file or directory)
[pid 4222] stat64("/var/www/html/archive/", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
[pid 4222] stat64("/var/www/html/archive/", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
What am I overlooking?
needed to add a command to the html section above the server!
working fine now! thanks to @RichardSmith for the good will
credit here
my config now starts: