技术解析
主页访问正常:
- share
- book
- music
- image
- film
访问子链接就报 403 error:
2016/09/11 18:39:18 [error] 22904#0: *1 open() "/media/pi/ITABAS/Book" failed (13: Permission denied),
client: 192.168.11.201, server: ~^\d+\.\d+\.\d+\.\d+$, request: "GET /Book HTTP/1.1",...
外接硬盘目录结构及权限, 用户 pi
[email protected]:/ $ ls -al /media/pi/ITABAS/
total 8
drwx------ 1 pi pi 4096 Sep 10 01:10 .
drwxr-x---+ 3 root root 4096 Sep 8 22:13 ..
drwx------ 1 pi pi 176 Sep 11 19:40 Book
drwx------ 1 pi pi 168 Sep 11 01:21 download
drwx------ 1 pi pi 0 Sep 9 23:07 Film
drwx------ 1 pi pi 144 Sep 10 00:13 Image
drwx------ 1 pi pi 160 Sep 10 00:12 Music
drwx------ 1 pi pi 0 Sep 9 23:07 Photo
sudo chown -R www-data:www-data /media/pi/ITABAS/
sudo chmod 755 /media/pi/ITABAS/
执行后权限无变化
Index 主页目录及权限
[email prot国外服务器ected]:/ $ ls -al /var/www/nas/
total 16
drwxr-xr-x 2 www-data www-data 4096 Sep 11 18:18 .
drwxr-xr-x 5 root root 4096 Sep 11 12:30 ..
-rw-r--r-- 1 www-data www-data 451 Sep 11 18:18 index.html
-rw-r--r-- 1 www-data www-data 840 Sep 11 16:58 index.html.bk
NGINX 站点 conf 配置, nginx 默认用户 www-data
server {
listen 8080 default_server;
root /media/pi/ITABAS;
server_name ~^\d+\.\d+\.\d+\.\d+$;
location / {
root /var/www/nas/;
index index.html index.htm index.nginx-debian.html;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /download {
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
allow all;
}
location /Book {
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
allow all;
}
}
另外我的外接硬盘还做了 samba, 把 www-data 加进去也没有反应...
[usbhdd]
comment = HDD Media Storage
path = /media/pi/ITABAS/
browseable = yes
writable = yes
create mask = 0664
directory mask = 0775
valid users = root pi www-data
麻烦大家指点一下,谢谢~