S
S
Saha7072019-10-15 14:34:58
Nginx
Saha707, 2019-10-15 14:34:58

How to block files through Ngnix proxy?

The bottom line is that there are 2 servers, one comes to the second and displays the site through a proxy. What do you need?
You need to block access to the file so that access is only through site.ru/load.php?path=brain.png and to the site.ru/files/brain.png link so that it gives an error 444 . Or another option to have access only for search engines through Referer. Who knows how to arrange this through a proxy, what should be written where?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Araik, 2019-10-15
@NinjaNickName

If the files are in the same directory, then you can simply deny access to the directory:

location ^~ /files/ {
deny all;
return 444;
}

Here is another useful link https://habr.com/ru/post/151795/

S
Saha707, 2019-10-15
@Saha707

And if I close the directory completely, how then to give the file?
And how to block access through a proxy server for Referer?
And if in different directories /files/ /photo/ /video/
Another such error when redirecting
2019/10/14 22:34:04 [error] 10384#10384: *457 open() "/etc/nginx/htmlsite.ru /files/brain.png" failed (2: No such file or directory), client: 15.24.571.95, server: site.ru, request: "GET /load.php?path=brain.png HTTP/1.0", upstream : "45.65.233.99:8080/load.php?path=brain.png", host: "site.ru", referrer: "site.ru"
header("X-Accel-Redirect: /files/".$path );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question