I have a Django web app that utilizes an nginx reverse proxy with a gunicorn application server (upstream).
My nginx logs are filling up with errors like these: 2020/03/03 22:51:57 [error] 9605#9605: *162393 upstream sent too big header while reading response header from upstream, client: 168.155.46.104, server: example.com, request: "GET /static/img/favicons/manifest.json HTTP/2.0", upstream: "http://unix:/home/ubuntu/app/myproj/gunicorn.sock:/static/img/favicons/manifest.json", host: "example.com", referrer: "https://example.com/signup/create-pass/new/6d756265726e2d3131/18/"
I'm assuming gunicorn was unable to serve manifest.json.
This shouldn't have happened. I've created manifest.json and placed it in the relevant location. Using the Favicon checker at https://realfavicongenerator.net/ shows me this error:
The Web App Manifest at https://example/com/static/img/favicons/site.webmanifest cannot be downloaded. If I hit that url directly in the brower, I end up seeing a 502 Bad Gateway error.
How can I fix this?
I figured out the error.
Files placed in the /static/ folder in my project are supposed to be served directly via nginx. But the json file in question wasn't included in nginx conf in a manner that allowed it to be served by the web server.
Once I fixed that (see below), the manifest file was directly served by nginx (and gunicorn never came in the loop). Problem solved!
This is what I added to nginx's virtual host file to solve the issue: Notice this includes the json extension:
location ~* \.(?:ico|css|js|gif|jpg|jpeg|png|svg|woff|ttf|eot|json)$ {
root /home/ubuntu/app/my_proj;
expires 120d;
access_log off;
error_log off;
}