[crit] 17067#0: *4093530 open() "/home/nginx//client_body_temp/0000048707"
failed (13: Permission denied), client: 127.0.0.1,server: localhost, request: "POST /url/create HTTP/1.1", host: "127.0.0.1"
[error] 17067#0: *4093530 open() "/home/nginx//html/50x.html" failed (13: P
ermission denied), client: 127.0.0.1, server: localhost, request: "POST /url/create HTTP/1.1", host: "127.0.0.1"
原因1:请求体太大,默认只有1m,可设置max body
nginx中的client_max_body_size配置项用来限制客户端发送给服务器的请求正文的最大字节数。这个配置项可以在http, server, location级别配置,如果在location中配置,那么会覆盖server级别的配置。默认值是1m。
设置方法如下:
http {
client_max_body_size 10m;
...
}
或者
server {
client_max_body_size 20m;
...
}
或者
location /upload {
client_max_body_size 50m;
...
}
如果客户端发送的请求正文大小超过了设置的限制,nginx会返回413、500、403等错误码。
原因2:服务目录无权限访问
nginx服务由更高权限的账号启动,如root启动,但是worker为nginx等普通账号
chown nginx:nginx * -R
# 用root把nginx 停掉
nginx -s stop
# 用普通账号,如nginx 把服务重新启动
sudo -u nginx -iH
nginx -s /home/nginx/conf/nginx.conf