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 @@
+* Overview
+
+Vmod-dbrw is a Varnish Cache module implementing database-driven
+rewrite rules. Its intended use is for web sites that need an
+exceedingly big number of redirect and/or rewrite rules. Vmod-dbrw
+allows you to keep all rules in an SQL database of arbitrary
+structure, considerably speeding up their handling. Another advantage
+of this approach is that rewrite rules stored in a database are easier
+to maintain.
+
+This version supports MySQL databases. Support for PostgreSQL will be
+added soon.
+
+* Example
+
+** Simplest case
+
+The redirection database has the following structure
+
+CREATE TABLE redirects (
+ host varchar(255) NOT NULL DEFAULT '',
+ url varchar(255) NOT NULL DEFAULT '',
+ dest varchar(255) DEFAULT NULL,
+ PRIMARY KEY (host,url)
+);
+
+VCL code:
+
+import dbrw;
+
+sub vcl_init {
+ dbrw.config("mysql", "database=dbname;user=varnish;debug=1",
+ "SELECT dest FROM redirects WHERE host='$host' AND url='$url'");
+}
+
+sub vcl_recv {
+ set req.http.X-Redirect-To =
+ dbrw.rewrite("host=" + req.http.Host + ";" +
+ "url=" + req.url);
+ if (req.http.X-Redirect-To) {
+ error(750, "Redirect");
+ }
+}
+
+sub vcl_error {
+ if (obj.status == 750) {
+ set obj.http.Location = req.http.X-Redirect-To;
+ set obj.status = 301;
+ return (deliver);
+ }
+}
+
+** More complex case: rewrites
+
+Table structure:
+
+CREATE TABLE rewrite (
+ host varchar(255) NOT NULL DEFAULT '',
+ url varchar(255) NOT NULL DEFAULT '',
+ dest varchar(255) DEFAULT NULL,
+ value varchar(255) DEFAULT NULL,
+ pattern varchar(255) DEFAULT NULL,
+ KEY source (host,url)
+)
+
+VCL code differs only in definition of the vcl_init:
+
+sub vcl_init {
+ dbrw.config("mysql", "database=varnish;user=varnish;debug=10",
+ {"SELECT dest,pattern,value FROM rewrite
+ WHERE host='$host' and '$url' like url"});
+}
+
+* Installation
+
+In order to compile the package you need to have Varnish source tree.
+At least Varnish 3.0.1 is required. Supposing that the varnish source tree
+is available under /usr/src/varnish-3.0.1, run:
+
+ ./configure --with-varnish-source=/usr/src/varnish-3.0.1 --with-vmod-dir
+
+The first option tells configure where Varnish sources reside, the
+second one (--with-vmod-dir) instructs it to place created module
+files to the standard Varnish module directory.
+
+Once configured, do
+
+ make
+
+This will build the module. After this step you can optionally run
+'make test' to test the package.
+
+Finally, do the following command as root:
+
+ make install
+
+
+* Bug reporting
+
+Send bug reports and suggestions to <gray@gnu.org>
+
+
+Local Variables:
+mode: outline
+paragraph-separate: "[ ]*$"
+version-control: never
+End:

Return to:

Send suggestions and report system problems to the System administrator.