403 forbidden for big media files nginx
I set up my Django server and it’s been operating for a while now. I experienced this really weird bug where certain files (>1MB) get rejected by Nginx.
error.log indicated the following as an example:
2017/06/27 01:03:29 [error] 1643#1643: *30 open() "/home/brian/nydkc11/nydkc11/nydkcd11/media/image_main/dtc1.jpg" failed (13: Permission denied), client: 220.127.116.11, server: nydkc11.org, request: "GET /media/image_main/dtc1.jpg HTTP/1.1", host: "nydkc11.org", referrer: "http://nydkc11.org/admin/blog/image/7/change/"
The weirdest thing is that Nginx serves static files on the <1MB just fine, and the problematic files serve perfectly on Django’s development server. Could someone tell me what’s going on and how I can fix the problem?
Note: I put
client_max_body_size 100M; to fix an Error 413 that emerged when I originally tried uploading the large file.
My droplet runs on Ubuntu 16.04, and utilizes Django, Gunicorn, and Nginx. I followed this tutorial to set it up:
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.