diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-08-05 19:50:12 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-08-05 20:21:05 +0300 |
commit | 625b9a4fa3c302715b06fcde8da3544f71cfe8b0 (patch) | |
tree | aa56be3b3129c8bfba769cfc9ec763ee3b1f9b69 /README | |
parent | aa3bfb206b14da4de737394d73098fb069b3d8ac (diff) | |
download | vmod-dbrw-625b9a4fa3c302715b06fcde8da3544f71cfe8b0.tar.gz vmod-dbrw-625b9a4fa3c302715b06fcde8da3544f71cfe8b0.tar.bz2 |
Switch to new acvmod. Remove the --with-varnish-source option. Fix the testsuite.
Diffstat (limited to 'README')
-rw-r--r-- | README | 72 |
1 files changed, 29 insertions, 43 deletions
@@ -1,5 +1,5 @@ | |||
1 | Vmod-dbrw README | 1 | Vmod-dbrw README |
2 | Copyright (C) 2013-2014 Sergey Poznyakoff | 2 | Copyright (C) 2013-2017 Sergey Poznyakoff |
3 | See the end of file for copying conditions. | 3 | See the end of file for copying conditions. |
4 | 4 | ||
5 | * Introduction | 5 | * Introduction |
@@ -46,43 +46,14 @@ The redirection database has the following structure | |||
46 | PRIMARY KEY (host,url) | 46 | PRIMARY KEY (host,url) |
47 | ); | 47 | ); |
48 | 48 | ||
49 | VCL 3.x code: | 49 | The VCL code: |
50 | 50 | ||
51 | import dbrw; | 51 | import dbrw; |
52 | 52 | ||
53 | sub vcl_init { | ||
54 | dbrw.config("mysql", "database=dbname;user=varnish;debug=1", | ||
55 | "SELECT dest FROM redirects WHERE host='$host' AND url='$url'"); | ||
56 | } | ||
57 | |||
58 | sub vcl_recv { | 53 | sub vcl_recv { |
59 | set req.http.X-Redirect-To = | 54 | dbrw.config("mysql", "database=dbname;user=varnish;debug=1", |
60 | dbrw.rewrite("host=" + req.http.Host + ";" + | ||
61 | "url=" + req.url); | ||
62 | if (req.http.X-Redirect-To != "") { | ||
63 | error(750, "Redirect"); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | sub vcl_error { | ||
68 | if (obj.status == 750) { | ||
69 | set obj.http.Location = req.http.X-Redirect-To; | ||
70 | set obj.status = 301; | ||
71 | return (deliver); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | VCL 4.0 code: | ||
76 | |||
77 | import dbrw; | ||
78 | |||
79 | sub vcl_init { | ||
80 | dbrw.config("mysql", "database=dbname;user=varnish;debug=1", | ||
81 | "SELECT dest FROM redirects WHERE host='$host' AND url='$url'"); | 55 | "SELECT dest FROM redirects WHERE host='$host' AND url='$url'"); |
82 | } | 56 | set req.http.X-Redirect-To = |
83 | |||
84 | sub vcl_recv { | ||
85 | set req.http.X-Redirect-To = | ||
86 | dbrw.rewrite("host=" + req.http.Host + ";" + | 57 | dbrw.rewrite("host=" + req.http.Host + ";" + |
87 | "url=" + req.url); | 58 | "url=" + req.url); |
88 | if (req.http.X-Redirect-To != "") { | 59 | if (req.http.X-Redirect-To != "") { |
@@ -110,9 +81,9 @@ Table structure: | |||
110 | KEY source (host,url) | 81 | KEY source (host,url) |
111 | ) | 82 | ) |
112 | 83 | ||
113 | VCL code differs only in definition of the vcl_init: | 84 | The VCL code differs only in the call to dbrw.config in vcl_recv: |
114 | 85 | ||
115 | sub vcl_init { | 86 | sub vcl_recv { |
116 | dbrw.config("mysql", "database=varnish;user=varnish;debug=10", | 87 | dbrw.config("mysql", "database=varnish;user=varnish;debug=10", |
117 | {"SELECT dest,pattern,value FROM rewrite | 88 | {"SELECT dest,pattern,value FROM rewrite |
118 | WHERE host='$host' and '$url' like url"}); | 89 | WHERE host='$host' and '$url' like url"}); |
@@ -120,18 +91,33 @@ VCL code differs only in definition of the vcl_init: | |||
120 | 91 | ||
121 | * Installation | 92 | * Installation |
122 | 93 | ||
123 | In order to compile the package you need to have Varnish source tree. | 94 | In order to compile the package you need to have installed |
124 | Both Varnish 3.x and 4.x are supported. Supposing that the Varnish | 95 | varnishd and varnishapi package. |
125 | source tree is available under /usr/src/varnish-3.0.1, run: | 96 | |
97 | Supposing that condition is met, run: | ||
98 | |||
99 | ./configure | ||
100 | |||
101 | It should be able to automatically find the necessary components. In case | ||
102 | it doesn't, tweak the configuration variables as necessary. The most | ||
103 | important one is PKG_CONFIG_PATH, which contains a path (in the UNIX sense) | ||
104 | where the .pc files are located. It should contain a directory where the | ||
105 | 'varnishapi.pc' file lives. Example usage: | ||
126 | 106 | ||
127 | ./configure --with-varnish-source=/usr/src/varnish-3.0.1 | 107 | ./configure PKG_CONFIG_PATH=/usr/local/varnish/lib/pkgconfig:$PKG_CONFIG_PATH |
108 | |||
109 | Please read the file INSTALL for a detailed discussion of available variables | ||
110 | and command line options. | ||
128 | 111 | ||
129 | Once configured, do | 112 | Once configured, do |
130 | 113 | ||
131 | make | 114 | make |
132 | 115 | ||
133 | This will build the module. Finally, do the following command as root: | 116 | This will build the module. After this step you can optionally run |
134 | 117 | 'make test' to test the package. | |
118 | |||
119 | Finally, run the following command as root: | ||
120 | |||
135 | make install | 121 | make install |
136 | 122 | ||
137 | * Testing | 123 | * Testing |
@@ -237,7 +223,7 @@ Send bug reports and suggestions to <gray@gnu.org> | |||
237 | 223 | ||
238 | * Copyright information: | 224 | * Copyright information: |
239 | 225 | ||
240 | Copyright (C) 2013-2014 Sergey Poznyakoff | 226 | Copyright (C) 2013-2017 Sergey Poznyakoff |
241 | 227 | ||
242 | Permission is granted to anyone to make or distribute verbatim copies | 228 | Permission is granted to anyone to make or distribute verbatim copies |
243 | of this document as received, in any medium, provided that the | 229 | of this document as received, in any medium, provided that the |