Answer the question
In order to leave comments, you need to log in
How to disable direct requests to nginx static files?
I need the styles of the project to be loaded in the html code of the page. Static files in django are usually located in static and are available under the /static/ path. However, I don't want anyone poking around in a directory with static files. How to do it? How to prevent get requests directly to .../static/some.js, but allow them for caching and Django?
Rule for static in nginx config:
location /static/ {
autoindex off;
alias /home/project/app/static/;
expires 30d;
}
Answer the question
In order to leave comments, you need to log in
No way. Maximum - you can block requests without a referral, but this is very easy to bypass.
No way.
Everything that is available to the client for download is available to him even in the body of the page, even through a direct link.
The maximum that can be done is to check the referee, but the meaning of this is about zero.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question