我在远程目录中有一个文件,它被转换为 apache DocRoot 树。当我尝试从该目录下载文件(而不是写入)时,我得到 403:
AH00037: Symbolic link not allowed or link target not accessible: /var/www/b2b/web/var
我尝试了什么:
- Selinux 被禁用
Options +FollowSymLinks
存在- 如果我用同一个 FS 上的链接替换另一个 FS 的链接 - 它可以工作!
文件:
namei -l /var/www/b2b/web/var/assets/75259_box1_v29.jpg
f: /var/www/b2b/web/var/assets/75259_box1_v29.jpg
dr-xr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root www
drwxrwxrwx www-data www-data b2b
drwxrwxrwx www-data www-data web
lrwxrwxrwx root root var -> /var/www/b2b/nfs/b2b-web-var
dr-xr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root www
drwxrwxrwx www-data www-data b2b
drwxrwxrwx www-data www-data nfs
drwxrwxrwx www-data www-data b2b-web-var
drwxrwxrwx www-data www-data assets
-rwxrwxrwx www-data www-data 75259_box1_v29.jpg
所以,在/var/www/b2b/web/
我有:
lrwxrwxrwx 1 root root 28 Oct 3 09:10 var -> /var/www/b2b/nfs/b2b-web-var
我创建var1
的内容与 /var/www/b2b/nfs/b2b-web-var 相同,如果我喜欢下面的内容(链接是本地的),那么一切正常:
lrwxrwxrwx 1 root root 4 Oct 3 18:15 var -> var1
drwxr-xr-x 4 root root 4096 Oct 3 18:13 var1
/etc/fstab:
fs-1111111111:/ /var/www/b2b/nfs efs defaults,_netdev 0 0
DocumentRoot 是/var/www/b2b/web
我也试过strace
了,但不明白到底出了什么问题:
[pid 11381] stat("/var/www/b2b/web/var/assets/75259_box1_v29.jpg", [wait(0x857f) = 11381] WIFSTOPPED,sig=133
{st_mode=S_IFREG|0777, st_size=201249, ...}) = 0
[pid 11381] gettimeofday( [wait(0x857f) = 11381] WIFSTOPPED,sig=133
[pid 11419] semop(2326532, {{0, -1, SEM_UNDO|IPC_NOWAIT}}, 1 <unfinished ...>
[pid 11416] semop(2326532, {{0, -1, SEM_UNDO|IPC_NOWAIT}}, 1 <unfinished ...>
[pid 11381] stat("/var/www/b2b/web/var/assets/75259_box1_v29.jpg", [wait(0x857f) = 11419] WIFSTOPPED,sig=133
[pid 11419] <... semop resumed> ) = -1 EAGAIN (Resource temporarily unavailable)
[pid 11416] <... semop resumed> ) = -1 EAGAIN (Resource temporarily unavailable)
[pid 11381] <... stat resumed> {st_mode=S_IFREG|0777, st_size=201249, ...}) = 0
[pid 11381] lstat("/var/www/b2b/web/var", [wait(0x857f) = 11381] WIFSTOPPED,sig=133
[pid 11381] stat("/var/www/b2b/web/var", [wait(0x857f) = 11381] WIFSTOPPED,sig=133
[pid 11381] gettimeofday( [wait(0x857f) = 11381] WIFSTOPPED,sig=133
[pid 11381] write(7, "[Thu Oct 03 18:34:35.430672 2019"..., 175 [wait(0x857f) = 11381] WIFSTOPPED,sig=133
[pid 11381] gettimeofday( [wait(0x857f) = 11381] WIFSTOPPED,sig=133
[pid 11381] read(12, [wait(0x857f) = 11381] WIFSTOPPED,sig=133
0x555c658e7068, 8000) = -1 EAGAIN (Resource temporarily unavailable)
[pid 11381] gettimeofday( [wait(0x857f) = 11381] WIFSTOPPED,sig=133
[pid 11381] writev(12, [{"HTTP/1.1 403 Forbidden\r\nDate: Th"..., 172}, {"<!DOCTYPE HTML PUBLIC \"-//IETF//"..., 357}], 2 [wait(0x857f) = 11381] WIFSTOPPED,sig=133
我考虑过超时,但我可以使用su apache
then 读取文件内容,例如 with head /var/www/b2b/web/var/assets/75259_box1_v29.jpg | less
。那么,这里有什么问题?
解决方案:符号链接的所有者必须与网站的其余部分相同:
注意:
-SymLinksIfOwnerMatch
在我的情况下还不够,我知道为什么。注意2:不要忘记'-h',否则 chownn 将在应用的目标上,而不是在链接本身上。如果你想 chown 链接到目录,那么不要添加斜杠!