aboutsummaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-07-10 15:16:05 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2013-07-12 11:50:07 +0300
commit8afb551c895d6870b0d4f427fa8205ae45ad0bf9 (patch)
tree6e208d7a54d2845035b366a906b35b390ccce96a /README
downloadvmod-dbrw-8afb551c895d6870b0d4f427fa8205ae45ad0bf9.tar.gz
vmod-dbrw-8afb551c895d6870b0d4f427fa8205ae45ad0bf9.tar.bz2
Initial commit
Diffstat (limited to 'README')
-rw-r--r--README107
1 files changed, 107 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..b177149
--- /dev/null
+++ b/README
@@ -0,0 +1,107 @@
1* Overview
2
3Vmod-dbrw is a Varnish Cache module implementing database-driven
4rewrite rules. Its intended use is for web sites that need an
5exceedingly big number of redirect and/or rewrite rules. Vmod-dbrw
6allows you to keep all rules in an SQL database of arbitrary
7structure, considerably speeding up their handling. Another advantage
8of this approach is that rewrite rules stored in a database are easier
9to maintain.
10
11This version supports MySQL databases. Support for PostgreSQL will be
12added soon.
13
14* Example
15
16** Simplest case
17
18The redirection database has the following structure
19
20CREATE TABLE redirects (
21 host varchar(255) NOT NULL DEFAULT '',
22 url varchar(255) NOT NULL DEFAULT '',
23 dest varchar(255) DEFAULT NULL,
24 PRIMARY KEY (host,url)
25);
26
27VCL code:
28
29import dbrw;
30
31sub vcl_init {
32 dbrw.config("mysql", "database=dbname;user=varnish;debug=1",
33 "SELECT dest FROM redirects WHERE host='$host' AND url='$url'");
34}
35
36sub vcl_recv {
37 set req.http.X-Redirect-To =
38 dbrw.rewrite("host=" + req.http.Host + ";" +
39 "url=" + req.url);
40 if (req.http.X-Redirect-To) {
41 error(750, "Redirect");
42 }
43}
44
45sub vcl_error {
46 if (obj.status == 750) {
47 set obj.http.Location = req.http.X-Redirect-To;
48 set obj.status = 301;
49 return (deliver);
50 }
51}
52
53** More complex case: rewrites
54
55Table structure:
56
57CREATE TABLE rewrite (
58 host varchar(255) NOT NULL DEFAULT '',
59 url varchar(255) NOT NULL DEFAULT '',
60 dest varchar(255) DEFAULT NULL,
61 value varchar(255) DEFAULT NULL,
62 pattern varchar(255) DEFAULT NULL,
63 KEY source (host,url)
64)
65
66VCL code differs only in definition of the vcl_init:
67
68sub vcl_init {
69 dbrw.config("mysql", "database=varnish;user=varnish;debug=10",
70 {"SELECT dest,pattern,value FROM rewrite
71 WHERE host='$host' and '$url' like url"});
72}
73
74* Installation
75
76In order to compile the package you need to have Varnish source tree.
77At least Varnish 3.0.1 is required. Supposing that the varnish source tree
78is available under /usr/src/varnish-3.0.1, run:
79
80 ./configure --with-varnish-source=/usr/src/varnish-3.0.1 --with-vmod-dir
81
82The first option tells configure where Varnish sources reside, the
83second one (--with-vmod-dir) instructs it to place created module
84files to the standard Varnish module directory.
85
86Once configured, do
87
88 make
89
90This will build the module. After this step you can optionally run
91'make test' to test the package.
92
93Finally, do the following command as root:
94
95 make install
96
97
98* Bug reporting
99
100Send bug reports and suggestions to <gray@gnu.org>
101
102
103Local Variables:
104mode: outline
105paragraph-separate: "[ ]*$"
106version-control: never
107End:

Return to:

Send suggestions and report system problems to the System administrator.