aboutsummaryrefslogtreecommitdiff
path: root/doc/vmod-dbrw.3
diff options
context:
space:
mode:
Diffstat (limited to 'doc/vmod-dbrw.3')
-rw-r--r--doc/vmod-dbrw.3105
1 files changed, 5 insertions, 100 deletions
diff --git a/doc/vmod-dbrw.3 b/doc/vmod-dbrw.3
index 8c89cc4..139fbab 100644
--- a/doc/vmod-dbrw.3
+++ b/doc/vmod-dbrw.3
@@ -1,5 +1,5 @@
.\" This file is part of Vmod-dbrw -*- nroff -*-
-.\" Copyright (C) 2013-2014 Sergey Poznyakoff
+.\" Copyright (C) 2013-2017 Sergey Poznyakoff
.\"
.\" Vmod-dbrw is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with vmod-dbrw. If not, see <http://www.gnu.org/licenses/>.
-.TH VMOD-DBRW 1 "April 21, 2016" "VMOD-DBRW" "User Reference"
+.TH VMOD-DBRW 1 "August 5, 2017" "VMOD-DBRW" "User Reference"
.SH NAME
vmod-dbrw \- Database-driven rewrite rules for Varnish Cache
.SH SYNOPSIS
@@ -188,7 +188,7 @@ CREATE TABLE redirects (
);
.EE
.PP
-VCL 3.0 code:
+The VCL code:
.PP
.EX
sub vcl_recv {
@@ -201,38 +201,6 @@ sub vcl_recv {
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);
- }
-}
-.EE
-.PP
-Notice the use of concatenation to build the argument to
-\fBdbrw.rewrite\fR.
-.PP
-The following is the same code for VCL 4.0:
-.PP
-.EX
-sub vcl_init {
- dbrw.config("mysql", "database=dbname;user=varnish",
- {"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 != "") {
return(synth(301, "Redirect"));
}
}
@@ -260,50 +228,15 @@ CREATE TABLE rewrite (
)
.EE
.PP
-VCL 3.0 code:
+The VCL:
.PP
.EX
-import std;
-import dbrw;
-
-sub vcl_init {
+sub vcl_recv {
# It is supposed that the url column contains an SQL-style
# wildcard pattern.
dbrw.config("mysql", "database=varnish;user=varnish;debug=10",
{"SELECT dest,pattern,value,flags FROM rewrite
WHERE host='$host' and '$url' like 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");
- }
-}
-.EE
-.PP
-The \fBvcl_error\fR function uses the \fBX\-VMOD\-DBRW\-Status\fR
-header, which may be set by \fBredirect=\fR flag in the
-\fBflags\fR column. Its value is converted to integer using the
-\fBinteger\fR function from the \fBstd\fR module. If the header is
-not set, permanent redirect is assumed:
-.PP
-.EX
-sub vcl_error {
- if (obj.status == 750) {
- set obj.http.Location = req.http.X-Redirect-To;
- set obj.status = std.integer(req.http.X-VMOD-DBRW-Status, 301);
- return (deliver);
- }
-}
-.EE
-.PP
-For VCL 4.0, \fBvcl_synth\fR is used instead of \fBvcl_error\fR:
-.PP
-.EX
-sub vcl_recv {
set req.http.X-Redirect-To =
dbrw.rewrite("host=" + req.http.Host + ";" +
"url=" + req.url);
@@ -320,34 +253,6 @@ sub vcl_synth {
}
}
.EE
-.SS Use of vmod-dbrw and vmod-redirect
-.PP
-.ie "\*[.T]"html" \{\
-For VCL 3.0 you can use the
-.URL https://www.varnish-cache.org/vmod/redirect \fBvmod-redirect\fR " module"
-\}
-.el \{\
-For VCL 3.0 you can use the \fBvmod-redirect\fR module
-.BR ( https://www.varnish-cache.org/vmod/redirect )
-\}
-and get rid of the \fBvcl_error\fR subroutine:
-.PP
-.EX
-import std;
-import dbrw;
-import redirect;
-
-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(redirect.location(
- std.integer(req.http.X-VMOD-DBRW-Status, 301),
- req.http.X-Redirect-To), "Redirection");
- }
-}
-.EE
.\" The MANCGI variable is set by man.cgi script on Ulysses.
.\" The download.inc file contains the default DOWNLOAD section
.\" for man-based doc pages.

Return to:

Send suggestions and report system problems to the System administrator.