Answer the question
In order to leave comments, you need to log in
How to prevent direct access to a file in nginx?
Good day.
Tell me if it is possible somehow in nginx to prohibit direct access to a PDF file by making redirects when directly accessing pdf files to the corresponding html pages. But these pdfs are loaded in iframes on html pages and should remain working.
Answer the question
In order to leave comments, you need to log in
You can check which page the request came from - but this is simply faked and will stop enthusiasts rather than professionals. In general, access resolution is usually done in the giblets of the site engine, and not with the help of nginx - this is not his job.
make a controller that will return the content of the files and check acl or whatever you have there, and place the files themselves in an inaccessible folder above the root of the site
https://sysadmin.pm/referrer-spam-nginx/
see valid_referers example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question