nginx serving corrupt images

Maxim Dounin mdounin at mdounin.ru
Thu Feb 23 02:28:09 UTC 2023


Hello!

On Wed, Feb 22, 2023 at 07:35:54PM -0500, Saint Michael wrote:

> a) The error does not have a single line.
> b) restarting does not fix it
> c) my nginx is no acting as proxy

So it's certainly unrelated to the article about proxying and 
error propagation you've previously linked.

> d) it happened twice and both times I fixed it by turning gzip off,
> restarting, and back on.
> e) I also noticed that I requested the image file with wget, get a full
> HTML file for the whole document, but named as if it were the image file.
> 
> wget https://x3x.us/index_files/image001.jpg
> but `stat image001.jpg' showed it was the entire text HTML file.

Your configuration contains:

  try_files $uri $uri/ /index.html;

so returning "/index.html" for all non-existing files is what 
nginx is configured to do.

Are you sure the file you are requesting actually exists?  Is the 
file system with these files local, or it's something distributed 
and/or some network filesystem?  Are files static, or generated 
and/or synced from somewhere?

You may want to try removing the "try_files" directive, so nginx 
will be able to properly respond with 404 on non-existing files, 
and will log errors with details about attempts to request them.  
Such errors will look like:

2023/02/23 05:16:25 [error] 80125#100117: *1 open() "/path/to/file" failed (2: No such file or directory), client: ...

This should help to identify exact files being requested, so 
you'll be able to check them manually, as will contain exact error 
code, so it will be possible to identify various permission 
issues.

Hope this helps.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list