Lighttpd:特定的~用户目录 404
Lighttpd: specific ~user directory 404
我正在尝试让用户目录与 Arch 上的 Lighttpd 一起工作 Linux。但是在创建 public_html 目录、在其中放置一个 index.html 文件、设置权限、配置 Lighttpd 以使用用户目录模块并重新启动 lighttpd 之后,它仍然为一个特定用户提供 404(又一个作品)。
这是我的配置文件:
$ cat /etc/lighttpd/lighttpd.conf
# This is a minimal example config
# See /usr/share/doc/lighttpd
# and http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions
server.port = 80
server.username = "http"
server.groupname = "http"
server.document-root = "/srv/http"
server.errorlog = "/var/log/lighttpd/error.log"
dir-listing.activate = "enable"
index-file.names = ( "index.html" )
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".css" => "text/css",
".js" => "application/x-javascript",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".gif" => "image/gif",
".png" => "image/png",
"" => "application/octet-stream"
)
include "conf.d/userdir.conf"
include "conf.d/cgi.conf"
$ cat /etc/lighttpd/conf.d/userdir.conf
server.modules += ( "mod_userdir" )
userdir.path = "public_html"
用户 aardbei 的情况如下:
$ cat /home/aardbei/public_html/index.html
doot doot
$ ls -ld /home/aardbei/public_html
drwxrwxrwx 2 aardbei aardbei 4096 Mar 27 13:10 /home/aardbei/public_html
$ ls -ld /home/aardbei/public_html/index.html
-rwxrwxrwx 1 aardbei aardbei 37 Mar 27 13:11 /home/aardbei/public_html/index.html
但即使在使用 sudo systemctl restart lighttpd
重新启动服务器后,我仍然在 URI /~aardbei/index.html
处得到 404 而不是我应该得到的:"doot doot"
然而,这就是用户 madeline 的样子:
$ cat /home/madeline/public_html/index.html
blah blah blah
$ ls -ld /home/madeline/public_html/
drwxrwxrwx 19 madeline madeline 4096 Mar 27 13:33 /home/madeline/public_html/
$ ls -ld /home/madeline/public_html/index.html
-rw-r--r-- 1 madeline madeline 15 Mar 27 13:33 /home/madeline/public_html/index.html
所以重要的部分是一样的。然而去 URI /~madeline/index.html
做它应该做的:它显示 "blah blah blah"
这里看起来没有什么相关的,但是这里有两个用户的组:
$ groups madeline
wheel video audio wireshark madeline
$ groups aardbei
wheel aardbei
这是怎么回事?为什么用户 aardbei 的用户目录在 Lighttpd 中不起作用?
按照 Arch Linux wiki for Apache 上的说明进行操作:https://wiki.archlinux.org/index.php/Apache_HTTP_Server#User_directories
$ chmod o+x /home/aardbei
$ chmod o+x /home/aardbei/public_html
$ chmod -R o+r /home/aardbei/public_html
我仍然不确定我是否理解这里的权限,但它解决了我的问题。
接受的答案之所以有效,是因为用户的网络服务器 运行 需要访问用户的主目录才能访问他们的 public_html
。
授予o+x
允许其他用户访问文件and/or 子目录但不允许他们列出目录的内容。基本上他们只要知道他们要找什么就可以通过它,public_html
,但否则他们无法获得内容列表。
例子
这是我的主目录:
$ ls -dl /home/sam
drwx-----x. 3 sam sam 4096 Nov 3 11:08 /home/sam
$ ls -dl /home/sam/public_html
drwxr-xr-x. 2 sam users 4096 Nov 3 11:09 /home/sam/public_html
现在作为网络服务器的用户,lighttpd
,无法列出我的主目录的内容:
$ sudo -u lighttpd ls /home/sam
ls: cannot open directory /home/sam: Permission denied
但是如果他们碰巧知道它的名字可以看到一个特定的目录:
$ ls -dl /home/sam/public_html
drwxr-xr-x. 2 sam users 4096 Nov 3 11:09 /home/sam/public_html
这是 Web 服务器也可以看到的另一个目录:
$ sudo -u lighttpd ls -ld /home/sam/someotherdir
drwx------. 2 sam users 4096 Nov 3 11:22 /home/sam/someotherdir
并且 public_html
中的文件也可见:
$ ls -dl /home/sam/public_html/index.html
-rw-r--r--. 1 sam users 3 Nov 3 11:09 /home/sam/public_html/index.html
普通权限适用于此处,因此如果您不希望网络服务器看到某些内容,请将其设置为对您的用户和组只读,而不是对其他所有人(其他人)。
我正在尝试让用户目录与 Arch 上的 Lighttpd 一起工作 Linux。但是在创建 public_html 目录、在其中放置一个 index.html 文件、设置权限、配置 Lighttpd 以使用用户目录模块并重新启动 lighttpd 之后,它仍然为一个特定用户提供 404(又一个作品)。
这是我的配置文件:
$ cat /etc/lighttpd/lighttpd.conf
# This is a minimal example config
# See /usr/share/doc/lighttpd
# and http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions
server.port = 80
server.username = "http"
server.groupname = "http"
server.document-root = "/srv/http"
server.errorlog = "/var/log/lighttpd/error.log"
dir-listing.activate = "enable"
index-file.names = ( "index.html" )
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".css" => "text/css",
".js" => "application/x-javascript",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".gif" => "image/gif",
".png" => "image/png",
"" => "application/octet-stream"
)
include "conf.d/userdir.conf"
include "conf.d/cgi.conf"
$ cat /etc/lighttpd/conf.d/userdir.conf
server.modules += ( "mod_userdir" )
userdir.path = "public_html"
用户 aardbei 的情况如下:
$ cat /home/aardbei/public_html/index.html
doot doot
$ ls -ld /home/aardbei/public_html
drwxrwxrwx 2 aardbei aardbei 4096 Mar 27 13:10 /home/aardbei/public_html
$ ls -ld /home/aardbei/public_html/index.html
-rwxrwxrwx 1 aardbei aardbei 37 Mar 27 13:11 /home/aardbei/public_html/index.html
但即使在使用 sudo systemctl restart lighttpd
重新启动服务器后,我仍然在 URI /~aardbei/index.html
处得到 404 而不是我应该得到的:"doot doot"
然而,这就是用户 madeline 的样子:
$ cat /home/madeline/public_html/index.html
blah blah blah
$ ls -ld /home/madeline/public_html/
drwxrwxrwx 19 madeline madeline 4096 Mar 27 13:33 /home/madeline/public_html/
$ ls -ld /home/madeline/public_html/index.html
-rw-r--r-- 1 madeline madeline 15 Mar 27 13:33 /home/madeline/public_html/index.html
所以重要的部分是一样的。然而去 URI /~madeline/index.html
做它应该做的:它显示 "blah blah blah"
这里看起来没有什么相关的,但是这里有两个用户的组:
$ groups madeline
wheel video audio wireshark madeline
$ groups aardbei
wheel aardbei
这是怎么回事?为什么用户 aardbei 的用户目录在 Lighttpd 中不起作用?
按照 Arch Linux wiki for Apache 上的说明进行操作:https://wiki.archlinux.org/index.php/Apache_HTTP_Server#User_directories
$ chmod o+x /home/aardbei
$ chmod o+x /home/aardbei/public_html
$ chmod -R o+r /home/aardbei/public_html
我仍然不确定我是否理解这里的权限,但它解决了我的问题。
接受的答案之所以有效,是因为用户的网络服务器 运行 需要访问用户的主目录才能访问他们的 public_html
。
授予o+x
允许其他用户访问文件and/or 子目录但不允许他们列出目录的内容。基本上他们只要知道他们要找什么就可以通过它,public_html
,但否则他们无法获得内容列表。
例子
这是我的主目录:
$ ls -dl /home/sam
drwx-----x. 3 sam sam 4096 Nov 3 11:08 /home/sam
$ ls -dl /home/sam/public_html
drwxr-xr-x. 2 sam users 4096 Nov 3 11:09 /home/sam/public_html
现在作为网络服务器的用户,lighttpd
,无法列出我的主目录的内容:
$ sudo -u lighttpd ls /home/sam
ls: cannot open directory /home/sam: Permission denied
但是如果他们碰巧知道它的名字可以看到一个特定的目录:
$ ls -dl /home/sam/public_html
drwxr-xr-x. 2 sam users 4096 Nov 3 11:09 /home/sam/public_html
这是 Web 服务器也可以看到的另一个目录:
$ sudo -u lighttpd ls -ld /home/sam/someotherdir
drwx------. 2 sam users 4096 Nov 3 11:22 /home/sam/someotherdir
并且 public_html
中的文件也可见:
$ ls -dl /home/sam/public_html/index.html
-rw-r--r--. 1 sam users 3 Nov 3 11:09 /home/sam/public_html/index.html
普通权限适用于此处,因此如果您不希望网络服务器看到某些内容,请将其设置为对您的用户和组只读,而不是对其他所有人(其他人)。