NGINX 403自动索引错误
我想让NGINX自动索引目录(\var\www\HTML\archive)。这是一个覆盆子馅饼 以下是与用户、服务器和位置相关的NGINX.conf位NGINX 403自动索引错误,nginx,permissions,http-status-code-403,mod-autoindex,Nginx,Permissions,Http Status Code 403,Mod Autoindex,我想让NGINX自动索引目录(\var\www\HTML\archive)。这是一个覆盆子馅饼 以下是与用户、服务器和位置相关的NGINX.conf位 #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;
#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;
}
}
顺便说一下,我尝试了所有不同的用户-包括root
在错误日志中,我有:
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"
但是我做了所有的chmod g+s,chmod 644文件等等
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
我相信上面的目录也可以:
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
我可以在/archive/中看到文件,例如,如果我转到10.0.0.16/archive/1d.png,则会显示图形
在其他职位上遵循了一些步骤:
[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
我忽略了什么?需要向服务器上方的html部分添加命令
autoindex on;
现在工作很好!
感谢@RichardSmith的好意
功劳
我的配置现在开始:
user pi;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
autoindex on; **** <--- HERE
...
用户pi;
工人自动处理;
pid/run/nginx.pid;
包括/etc/nginx/modules enabled/*.conf;
事件{
工人(768);;
#多重接受;
}
http{
##
#基本设置
##
发送文件到;
tcp_nopush on;
tcp_节点延迟开启;
保持生命超时65;
类型\散列\最大\大小2048;
#服务器_令牌关闭;
自动索引打开;****您的配置中还有其他server
块吗?您可以使用nginx-T
查看哪些文件nginx
正在读取,谢谢@Richard。我不这么认为,但我对运行服务器完全陌生。我将发布整个配置(为了清晰起见,删除了注释:另外,我运行了nginx-T,它确实显示了我一直在编辑的配置文件。我不知道它是否相关,但在配置文件之后,它列出了一堆模块,而autoindex不在其中。是否可能没有安装它?编辑配置文件后,您正在重新启动nginx
请轻松编辑您的问题并在那里添加相关信息。是的,我每次都会重新启动。我实际上有一个解决方案…请注意,这似乎已打开整个网站的自动索引。这对我来说并不重要,但请注意!