S
S
Slash2018-09-03 03:36:05
Nginx
Slash, 2018-09-03 03:36:05

How to block an IP range in Nginx?

Hello.
Here: https://nginx.org/ru/docs/http/ngx_http_access_mod... it says how to block an IP, as I understand it, you can do this:

location / {
    deny  141.8.183.11;
}

But what if the numbers after the second dot are constantly different? Is it possible to do so?
location / {
    deny  141.8.;
}

And: Context: http, server, location, limit_except - this means that you can insert into the file: "etc/nginx/nginx.conf", immediately after http { :
http {
    deny  141.8.183.11;

Or will the code only work in: "/etc/nginx/vhosts/www-root/site.net.conf" (can't check at the moment)?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
roswell, 2018-09-03
@Slash-Zn

If all are different after the second dot, then

location / {
    deny 141.8.0.0/16;
}

The context is, roughly speaking, the name of a section in the configuration.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question