nginx 静态资源 403
修改为有权限的用户
user nobody;
为
user user_00 users;
重启 nginx 即可
user 文档
user 用户 用户组;
静态 css 资源输出的 Content-Type 错误
Content-Type: text/html; charset=UTF-8
- 由于静态 css 资源的访问权限不足,导致其无法访问。
- 规则配置中,对于不存在的资源,请求将被转发到 index.php,所以输出的内容都是 php 的动态处理内容
跟踪 nginx 进程
- 将 nginx 的配置调整为 1 个 worker
- ps -ef | grep nginx 查看到 worker 对应的进程ID
- 跟踪进程ID,并发起异常请求,查看屏幕输出
$ sudo dtruss -p 8888
SYSCALL(args) = return
access("/etc/localtime\0", 0x4, 0x0) = 0 0
open_nocancel("/etc/localtime\0", 0x0, 0x0) = 3 0
fstat64(0x3, 0x7FFEE3BFCFF8, 0x0) = 0 0
read_nocancel(0x3, "TZif2\0", 0xA1E8) = 528 0
close_nocancel(0x3) = 0 0
issetugid(0x0, 0x0, 0x0) = 1 0
open_nocancel("/var/db/timezone/zoneinfo/posixrules\0", 0x0, 0x0) = 3 0
fstat64(0x3, 0x7FFEE3BFCE48, 0x0) = 0 0
read_nocancel(0x3, "TZif2\0", 0xA1E8) = 3519 0
close_nocancel(0x3) = 0 0
accept(0x6, 0x7FFEE3BFD580, 0x7FFEE3BFD57C) = 3 0
kevent(0xC, 0x7FAF2E02B200, 0x1) = 2 0
accept(0x6, 0x7FFEE3BFD580, 0x7FFEE3BFD57C) = 4 0
recvfrom(0x3, 0x7FAF2F001000, 0x400) = 690 0
open("/data/services/localhost/web/test.html\0", 0x4, 0x0) = -1 Err#13
write(0x9, "2018/11/07 17:04:19 [error] 8576#0: *611 open() \"/data/services/localhost/web/test.html\" failed (13: Permission denied), client: 127.0.0.1, server: localhost, request: \"GET /test.html HTTP/1.1\", host: \"localhost\"\n\0", 0xD5) = 213 0
writev(0x3, 0x7FFEE3BFCBA0, 0x5) = 400 0
write(0x8, "127.0.0.1 - - [07/Nov/2018:17:04:19 +0800] \"GET /test.html HTTP/1.1\" 403 199 \"-\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36\"\n\0", 0xCC) = 204 0