-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
63 lines (45 loc) · 1.17 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
NAME
ngx_http_referer_host_module - implements $referer_host variable
SYNOPSIS
http {
map $referer_host $valid {
default 0;
example.com 1;
www.example.com 1;
}
map $referer_host $invalid {
hostnames;
default 1;
.example.com 0;
}
...
server {
location / {
if ($invalid) {
return 403;
}
}
...
}
}
DESCRIPTION
A very simple module that parses http referer header and exports
resulting hostname into $referer_host variable to use in nginx.conf.
And just in case modifies referer header making its hostname part
lower-cased.
You can achieve something like this in nginx 0.9.6+ with map and pcre:
map $http_referer $referer_host {
default "";
~^https?://(?<H>[^:/]+) $H;
}
INSTALLATION
As usual for nginx modules:
./configure --add-module=/path/to/ngx_http_referer_host_module ...
make
make install
AUTHOR
Alexandr Gomoliako <[email protected]>
LICENSE
Copyright 2011 Alexandr Gomoliako. All rights reserved.
This module is free software. It may be used, redistributed and/or
modified under the terms described in LICENSE file.