set_real_ip_from --how to load IP list file ?

Maxim Dounin mdounin at mdounin.ru
Mon Nov 9 13:06:03 UTC 2015


Hello!

On Sun, Nov 08, 2015 at 02:47:03PM +0800, ...²º¹³ wrote:

> Hi,
>   I'm using CDN with my site.
> There are many IPs on network.
> set_real_ip_from only can add IP in one line.
> I want to add IP list to  file and load it .
> How to set ?

The "set_real_ip_from" directive understands not only IPs, but 
also networks in CIDR notation.  That is, if you want to enable 
real ip handling for a network, you can write something like:

    set_real_ip_from 192.168.1.0/24;

And this is recommended compared to listing individual addresses, 
as it's much faster to check.

There is no support for loading multiple addresses from a file.  
If you really want to load a list from a file, you can use the 
"include" directive, see http://nginx.org/r/include.  You'll have 
to convert your list to be valid nginx configuration with 
"set_real_ip_from" and ";" (something can be easily done with an 
awk or perl one-liner).

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list