gpt4 book ai didi

linux - nginx 的 apt-get 安装留下 root 拥有的文件

转载 作者:太空宇宙 更新时间:2023-11-04 11:10:54 25 4
gpt4 key购买 nike

在使用 apache httpd 多年后,我将转向 nginx。我使用 apt-get 安装 nginx 服务器并注意到所有文件都归 root 所有。

debian@nginx-explore:~$ ls -la /usr/share/nginx/www/
total 16
drwxr-xr-x 2 root root 4096 Apr 23 21:09 .
drwxr-xr-x 3 root root 4096 Apr 23 21:09 ..
-rw-r--r-- 1 root root 383 Jul 7 2006 50x.html
-rw-r--r-- 1 root root 151 Oct 4 2004 index.html

master 进程也归 root 所有,尽管有 worker 进程以 www-data 运行

debian@nginx-explore:~$ ps aux|grep nginx
root 2724 0.0 0.1 62348 1324 ? Ss Apr23 0:00 nginx: master process /usr/sbin/nginx
www-data 2725 0.0 0.1 62688 1624 ? S Apr23 0:03 nginx: worker process
www-data 2726 0.0 0.1 62688 1624 ? S Apr23 0:03 nginx: worker process
www-data 2727 0.0 0.1 62688 1624 ? S Apr23 0:03 nginx: worker process
www-data 2728 0.0 0.2 62688 2132 ? S Apr23 0:00 nginx: worker process

在 Apache 中,作为一项安全措施,始终强调确保文件和进程不归 root 所有。在使用 nginx 时这不是什么大问题有什么原因吗?

最终我需要知道我是否应该调整 nginx 文件和文件夹的所有权以确保我的系统安全。

最佳答案

由于文件归 root 所有,负责处理网络流量的 nginx 用户 (www-data) 无法通过安全漏洞或以其他方式允许对 www 文件进行写访问。因此,它遵循 principle of least privilege .

从另一方面来看,如果你将文件更改为 nginx 用户(www-data)拥有,那么就有可能利用 nginx worker 进程修改它拥有的文件,在这个保护您的 www 页面。

关于linux - nginx 的 apt-get 安装留下 root 拥有的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23274818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com