-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
122 lines (86 loc) · 3.19 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
- English
http://sourceforge.net/projects/modcidrlookup/
- Japanese
http://lab.klab.org/modules/mediawiki/index.php/Mod_cidr_lookup
* Overview
The mod_cidr_lookup is Apache module for version 2.2 and 2.0.
The mod_cidr_lookup detects client type by looking up client's source IP
address in CIDR blocks.
This module sets environment variable (X_CLIENT_TYPE) and HTTP request
header (X-Client-Type). So we can use it in both Apache (httpd.conf) and Web
application.
* Download
- http://sourceforge.net/projects/modcidrlookup/
* Installation
----------------------------------------------------------------
VER=1.0
tar zxf mod_cidr_lookup-${VER}.tar.gz
cd mod_cidr_lookup-${VER}/apache2
make
sudo make install
----------------------------------------------------------------
* Configuration
Firstly, load module.
----------------------------------------------------------------
LoadModule cidr_lookup_module modules/mod_cidr_lookup.so
----------------------------------------------------------------
The mod_cidr_lookup provide only one directive "CIDRFile".
** CIDRFile Directive
Description: set the name of a file containing the list of CIDR blocks
Syntax: CIDRFile file-path
Context: server config, virtual host, directory
Module: mod_cidr_lookup
The CIDRFile directive sets the name of a file containing the list of CIDR
blocks.
----------------------------------------------------------------
CIDRFile "/usr/local/etc/ip.d/crowler-google"
CIDRFile "/usr/local/etc/ip.d/crowler-yahoo"
CIDRFile "/usr/local/etc/ip.d/crowler-livedoor"
----------------------------------------------------------------
Shell-style (fnmatch()) wildcard characters can be used to load several
files at once, in alphabetical order.
----------------------------------------------------------------
CIDRFile "/usr/local/etc/ip.d/*"
CIDRFile "/usr/local/etc/ip.d/[a-z]*[a-z]"
----------------------------------------------------------------
The name of file become value of environment variable and HTTP request
header.
example:
- httpd.conf
----------------------------------------------------------------
<VirtualHost *:80>
ServerName ...
DocumentRoot /...
...
CIDRFile "/usr/local/etc/ip.d/foo"
CIDRFile "/usr/local/etc/ip.d/bar"
CIDRFile "/usr/local/etc/ip.d/baz"
</VirtualHost>
----------------------------------------------------------------
- CIDR files
----------------------------------------------------------------
$ cat /usr/local/etc/ip.d/foo
172.16.0.0/16
$ cat /usr/local/etc/ip.d/bar
10.0.1.0/24
10.1.1.0/24
10.2.1.0/24
$ cat /usr/local/etc/ip.d/baz
10.10.0.0/16
10.14.0.0/16
----------------------------------------------------------------
In case that client's source IP address is 10.1.1.61, this IP address match
second CIDR in file "bar". Hence value of environment variable
"X_CLIENT_TYPE" and HTTP request header "X-Client-Type" become "bar".
* Note
- You must stop and start or restart (send signal HUP, USR1) to apply
change of CIDR files.
* Authors
- HIROSE Masaaki
- YASUI Masanobu
- HAMANO Tsukasa
- INADA Naoki
* Contact
* License
- Apache License Version 2.0