Nginx – cannot upload regular sized files – permission denied

I’m having this weird error in nginx where it fails to upload regular sized images like 200KB up or so. It uploads fine when the is too small. Below is the exact error.

[crit] 796#0: *2397 open() "/var/lib/nginx/client_body/0000000003" failed (13: Permission denied)

To clarify, upload works on very small files, like below 200K but I’m not very sure about the exact limit. My current setup is a docker container with PHP and Apache and nginx in front that serve’s as proxy in the host machine to allow local domain names.

I found a post in StackOverflow where it is about the permission to the /var/lib/nginx directory. It seems that for small files, nginx does not write to these directories, but for larger files, it saves to disk and stream its way down to the application it proxies.

Tried to run the command below.

ls -l /var/lig/nginx/

It says that the directories are owned by nobody:root. However, the directory /var/lib/nginx directory itself is owned by root:root. Therefore, to fix, change ownership to nobody:root.

chown nobody:root /var/lib/nginx

No need to restart nginx.

Enjoy and share.

No Comments

Leave a reply

Your email address will not be published. Required fields are marked *