PNG files which are definitely existing on the server in the correct directory (I double-checked) throw a 404 Not found (nginx) error. The strange thing is that .pdf files which are also stored under the /public/storage/.../documents path are shown correctly. So, perhaps this is an nginx conf issue? I already checked permission of files and nginx conf.
Permissions of files:
The directory where the .png files are in has drwxrws---+ permissions and the files themselves have -rw-rwx---+ permissions. Note that also the .pdf files in the same dir which are displayed correctly have the exact same permissions.
Nginx configuration:
I took a look into invoiceninja5.conf under /etc/nginx/conf.d/domain.tld.d where I found the following:
location ~* \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
try_files $uri /var/www/invoiceninja5/public/index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
I’m not too deep into nginx config. Does this look correct considering the .png files are located under /public/storage/…/documents ?
Can anybody help with this? I want to be able to access my uploaded images in InvoiceNinja.
Following your advice @david I commented out the extra blog I posted above and reloaded nginx. Afterwards I can access my images via the dedicated link but there is still an ImageCodecException when embedding the image in InvoiceNinja. The error message is the following:
ImageCodecException: Failed to detect image file format using the file header.
File header was [0x3c 0x21 0x44 0x4f 0x43 0x54 0x59 0x50 0x45 0x20].
Image source: encoded image bytes: https://domain.tld/api/v1/...
I also ran php artisan optimize after reloading nginx. Still, the embedded image is not displayed correctly. What can I do? Thank you.
Thank you @hillel. I just checked my /etc/hosts file and it has this line
127.0.0.1 localhost
I don’t think this should produce any errors. Also please note that I am not running InvoiceNinja inside of a docker container. It’s installed natively on a Debian server and my error message is slightly different. It doesn’t say File header was empty as in your linked thread but File header was [...]. Any other suggestions?
I just wanted to give an update about this as I could solve it. My invoiceninja installation was behind an additional basic authentication and this caused the images not to render inline. After removing the additional basic auth and making invoiceninja publicly accessible the images render correctly inline. So, this is solved.