From 625b9a4fa3c302715b06fcde8da3544f71cfe8b0 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sat, 5 Aug 2017 19:50:12 +0300 Subject: Switch to new acvmod. Remove the --with-varnish-source option. Fix the testsuite. --- README | 72 +++++++++++++++++++++++++++--------------------------------------- 1 file changed, 29 insertions(+), 43 deletions(-) (limited to 'README') diff --git a/README b/README index 93f6f7e..a741783 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ Vmod-dbrw README -Copyright (C) 2013-2014 Sergey Poznyakoff +Copyright (C) 2013-2017 Sergey Poznyakoff See the end of file for copying conditions. * Introduction @@ -46,43 +46,14 @@ The redirection database has the following structure PRIMARY KEY (host,url) ); -VCL 3.x code: +The 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); - } - } - -VCL 4.0 code: - - import dbrw; - - sub vcl_init { - dbrw.config("mysql", "database=dbname;user=varnish;debug=1", + 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 = + set req.http.X-Redirect-To = dbrw.rewrite("host=" + req.http.Host + ";" + "url=" + req.url); if (req.http.X-Redirect-To != "") { @@ -110,9 +81,9 @@ Table structure: KEY source (host,url) ) -VCL code differs only in definition of the vcl_init: +The VCL code differs only in the call to dbrw.config in vcl_recv: - sub vcl_init { + sub vcl_recv { dbrw.config("mysql", "database=varnish;user=varnish;debug=10", {"SELECT dest,pattern,value FROM rewrite WHERE host='$host' and '$url' like url"}); @@ -120,18 +91,33 @@ VCL code differs only in definition of the vcl_init: * Installation -In order to compile the package you need to have Varnish source tree. -Both Varnish 3.x and 4.x are supported. Supposing that the Varnish -source tree is available under /usr/src/varnish-3.0.1, run: +In order to compile the package you need to have installed +varnishd and varnishapi package. + +Supposing that condition is met, run: + + ./configure + +It should be able to automatically find the necessary components. In case +it doesn't, tweak the configuration variables as necessary. The most +important one is PKG_CONFIG_PATH, which contains a path (in the UNIX sense) +where the .pc files are located. It should contain a directory where the +'varnishapi.pc' file lives. Example usage: - ./configure --with-varnish-source=/usr/src/varnish-3.0.1 + ./configure PKG_CONFIG_PATH=/usr/local/varnish/lib/pkgconfig:$PKG_CONFIG_PATH + +Please read the file INSTALL for a detailed discussion of available variables +and command line options. Once configured, do - + make -This will build the module. Finally, do the following command as root: - +This will build the module. After this step you can optionally run +'make test' to test the package. + +Finally, run the following command as root: + make install * Testing @@ -237,7 +223,7 @@ Send bug reports and suggestions to * Copyright information: -Copyright (C) 2013-2014 Sergey Poznyakoff +Copyright (C) 2013-2017 Sergey Poznyakoff Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the -- cgit v1.2.1