nginx - 尽管设置了权限,但 Nginx 出现 403 禁止错误

标签 nginx centos

我的实际问题是 Nginx 无法呈现页面(403 禁止),尽管 nginx:nginx 的权限设置为 755。

我正在使用以下命令...

[root@wfe1 user1]# strace -p 26934 -e trace=file
Process 26934 attached
stat("/home/user1/site3/index.html", {st_mode=S_IFREG|0755, st_size=6, ...}) = 0
open("/home/user1/site3/index.html", O_RDONLY|O_NONBLOCK) = -1 EACCES (Permission denied)

如您所见,输出是 Permission Denied。我想知道使用哪个用户帐户访问该文件?我怎样才能深入挖掘?

[root@wfe1 user1]# ls -al site3
total 8
drwxr-xr-x. 2 nginx nginx   23 Mar  6 06:12 .
drwx------. 5 user1 user1 4096 Mar  6 06:12 ..
-rwxr-xr-x. 1 nginx nginx    6 Mar  6 06:12 index.html

最佳答案

查看 nginx 访问日志,看看哪里出了问题

使用ps aux | grep nginx 查看正在运行的 nginx 用户。

确保您在 nginx 配置/位置节中设置了正确的“允许所有”权限。

关于nginx - 尽管设置了权限,但 Nginx 出现 403 禁止错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35858675/

相关文章:

git pull 文件给出 500 错误

ruby - `require' : cannot load such file - Running ruby from bash script

linux - 无法在端口 80 或 443 上运行 Node.js Web 服务

javascript - 如何在 Cookie 上强制 HttpOnly FALSE,以便 JavaScript 可以使用 PHP 跨域读取它们?

ubuntu - Nginx/Certbot - 来自域/.well-known 的无效响应

nginx - 此代码如何产生字符串 "nginx"?

node.js - 上传/部署 zip 文件时,不会创建 .platform Hook 中的 AWS Elastic Beanstalk 自定义 nginx .conf 文件

php - 从 nginx 中的不同位置提供 php 文件

Docker 容器基于 OSX 而不是 Amazon Linux 构建

ruby-on-rails - rails smtp 问题