Hi David,
If you have to use IP block,
maybe you should write some calculate function with hexadecimal.
IPv4 can convert hexadecimal. Then you can compare IP easily.
This is just my idea.
ex.
- calculate first(min) IP and last(max) IP, c0a80100 - c0a801ff
- you can also convert ngx.var.remote_addr to hexadecimal
- then you can calc coming ip is in range c0a80100 - c0a801ff or not
BTW I understand your use case and this idea is not useful for your case.
If you use my idea, you need to convert all whitelist IP block and compare. It is high cost.
Another idea is using NoSQL like memcached or just use ngx.shared.DICT.
ex.
- put all IP address in range to NoSQL like "{key: 192.168.1.0, value: true}", "{key: 192.168.1.1, value: true}", "{key: 192.168.1.2, value: true}" ... "{key: 192.168.1.255, value: true}"
*note* this is not nginx's work. you should prepare some client program for do that.
- Then you can compare very simple. you just ask to NoSQL that key: ngx.var.remote_addr is exist or not.
Sorry for my poor English.
2016年1月21日木曜日 4時30分24秒 UTC+9 David Santhosh: