F
F
Foxwar2016-10-09 19:19:37
System administration
Foxwar, 2016-10-09 19:19:37

How to implement access to the site page from certain Ip ranges through nginx?

I'm trying to implement access to the site page through nginx from certain ip addresses
, the first option is through allow deny, for some reason some javascripts work crookedly, instead of executing it, it offers to download it.
second option

if ($remote_addr !~ (aaa.bbb.ccc)|(ddd.eee.fff)|(ggg.hhh.iii)) {
return 444;
}

only works with single ip addresses, is it possible to insert a subnet?
the third option is through geo, but I don’t understand how to specify access to a specific folder
, this is how it looks for me
geo $bad_user {
default 0;
171.196.0.0/161;
171.198.0.0/161;
location 0 {
rewrite ^ www.example.com/123.html;
}
}

But as I understand it, this method will be used to redirect from the entire domain, but how to do it only from the /wp/234/ folder

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
arkitekt, 2016-10-10
@acyp

When implementing the third option in a specific location that defines a forbidden page, set the condition
server {
location page {
if ($bad_user = 1 ) {
return 403
; } I think if necessary, change the return page. without shoveling the entire config.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question