Welcome! Log In Create A New Profile

Advanced

Re: Deny ips, and pick ips from a file.

Anton Yuzhaninov
October 11, 2012 06:04AM
On 11.10.2012 09:50, Quintin Par wrote:
> I need to deny users by ip. I assume we need to do something like this
>
> location / {
>
> # block one workstation
>
> deny 192.168.1.1;
>
> # allow anyone in 192.168.1.0/24 http://192.168.1.0/24
>
> allow 192.168.1.0/24 http://192.168.1.0/24;
>
> # drop rest of the world
>
> deny all;
>
> }
>
> But how can I pass on the list of ips from a file? A file which will get udated
> from time to time.
>
> Can I pass the ips something like this
>
> deny /tmp/iplist.txt;

If list of IP to block is really big, then better to use geo module instead
allow/deny: http://nginx.org/en/docs/http/ngx_http_geo_module.html

geo $denyed_host {
default 1;
include /tmp/iplist.txt;
}

....

if ($denyed_host) {
return 403;
}

iplist.txt should contain lines like:

192.168.1.0/24 0;
192.168.1.1/32 1;

After update of /tmp/iplist.txt you should reconfigure nginx (e. g. run nginx -s
reload).

--
Anton Yuzhaninov

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Deny ips, and pick ips from a file.

Quintin Par October 11, 2012 01:58AM

Re: Deny ips, and pick ips from a file.

Anton Yuzhaninov October 11, 2012 06:04AM

Re: Deny ips, and pick ips from a file.

Wolfsrudel October 11, 2012 06:55AM

Re: Deny ips, and pick ips from a file.

António P. P. Almeida October 11, 2012 07:04AM

Re: Deny ips, and pick ips from a file.

Quintin Par October 13, 2012 01:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 159
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready