I
I
invisii2021-03-03 19:14:37
PHP
invisii, 2021-03-03 19:14:37

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

3 answer(s)
K
ky0, 2021-03-03
@ky0

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.

A
Anton Shamanov, 2021-03-03
@SilenceOfWinter

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

V
Viktor Taran, 2021-03-09
@shambler81

https://sysadmin.pm/referrer-spam-nginx/
see valid_referers example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question