S
S
samsvin2018-09-10 19:04:38
Nginx
samsvin, 2018-09-10 19:04:38

Set up a ban on images on the server through nginx?

It is necessary to prohibit on the current site sitq1 to prohibit opening images through the browser, and on the site2 to allow previews from site1 I'm
picking nginx, it doesn't work, I can't set up
location / {
proxy_pass http://000.000.000.000:8080;
location ~* ^.+\.(jpg|jpeg|txt|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf||mpg|wmv|exe|iso|dmg| swf)$ {
root /home/admin/web/site1/public_html;
access_log /var/log/httpd/domains/site1.log combined;
access_log /var/log/httpd/domains/site1.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
if you remove jpg from the first one and add a condition, then it blocks on site2
location ~* ^/m/.+\.(js|jpg)$ {
valid_referers none blocked site2 *.site2;
if ($invalid_referer) {return 403;}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Varlamov, 2018-09-11
@bes_internal

for site1:

location ~* .*\.(jpg)$ {
valid_referer site2;
if ($invalid_referer) {return 403;}
root ...
...
}

That is, none (empty referer) was removed.
We got the logic: if the referrer is from site2, then return it, otherwise return 403.
It's simple

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question