I’m running my project using Nginx and Gunicorn, I pulled changes and ran collectstatic command which resulted in having the static files in the root folder for the static files, the problem is like I have a picture ‘img.jpg’ Nginx is trying to access ‘img.jpg/index.html’
I got this information from /var/log/nginx/error.log
my Nginx configuration are:
location /static/ {
alias /path/to/staticfiles/;
}
This all looks right from what you’ve posted so far.
www.domain.com/static/path/file would be correct based upon your STATIC_URL setting and with your nginx location directive. The urls with .../staticfiles/... would not be valid.
If you have a page that is incorrectly referencing a file, we’d need to see the template involved.
Side note: As a general rule, you want to get your STATIC_ROOT moved to a directory outside your project - someplace that is more “nginx-friendly”, such as /var/www/html. (You can make it work the way you have it, but you typically end up granting more permissions to nginx than what would be considered “best practice”.)
Because you haven’t shown an nginx <alias or <location directive with /staticfiles/ in the url.
If it’s appending index.html to the requesting url, then that means you have something else wrong in the nginx configuration. We’d need to see your complete configuration for this project.
More accurately, when it receives a request for a url starting with /static/, that the files should be retrieved from the /path/to/staticfiles/ directory. But the url is /static/, not/staticfiles/.
Absolutely not. You have:
which means that Django will create the urls for the static files using static/. You are not generating any urls starting with staticfiles.
Side note - Using the single backtick - ` only works for text all on one line.
When you want to mark multiple lines, use three backticks - ```, with the three backticks on lines by themselves. (I took the liberty of correcting your post for this.)