Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
8931bc07
Commit
8931bc07
authored
Apr 16, 2012
by
Per Buer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
:: need to be on a separate line in RST.
parent
9a1b232b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
22 deletions
+44
-22
vcl.rst
doc/sphinx/reference/vcl.rst
+44
-22
No files found.
doc/sphinx/reference/vcl.rst
View file @
8931bc07
...
...
@@ -96,14 +96,16 @@ file as a quoted string.
Backend declarations
--------------------
A backend declaration creates and initializes a named backend object::
A backend declaration creates and initializes a named backend object:
::
backend www {
.host = "www.example.com";
.port = "http";
}
The backend object can later be used to select a backend at request time::
The backend object can later be used to select a backend at request time:
::
if (req.http.host ~ "(?i)^(www.)?example.com$") {
set req.backend = www;
...
...
@@ -118,7 +120,8 @@ backend connection, .first_byte_timeout for the time to wait for the
first byte from the backend and .between_bytes_timeout for time to
wait between each received byte.
These can be set in the declaration like this::
These can be set in the declaration like this:
::
backend www {
.host = "www.example.com";
...
...
@@ -145,7 +148,8 @@ be used.
There are several types of directors. The different director types
use different algorithms to choose which backend to use.
Configuring a director may look like this::
Configuring a director may look like this:
::
director b2 random {
.retries = 5;
...
...
@@ -226,7 +230,8 @@ The DNS director
~~~~~~~~~~~~~~~~
The DNS director can use backends in two different ways. Either like the
random or round-robin director or using .list::
random or round-robin director or using .list:
::
director directorname dns {
.list = {
...
...
@@ -266,7 +271,8 @@ considers them in the order in which they are listed in its definition.
The fallback director does not take any options.
An example of a fallback director::
An example of a fallback director:
::
director b3 fallback {
{ .backend = www1; }
...
...
@@ -312,7 +318,8 @@ Probes take the following parameters:
Default is 2 seconds.
A backend with a probe can be defined like this, together with the
backend or director::
backend or director:
::
backend www {
.host = "www.example.com";
...
...
@@ -326,7 +333,8 @@ backend or director::
}
}
Or it can be defined separately and then referenced::
Or it can be defined separately and then referenced:
::
probe healthcheck {
.url = "/status.cgi";
...
...
@@ -347,7 +355,8 @@ Or it can be defined separately and then referenced::
If you have many backends this can simplify the config a lot.
It is also possible to specify the raw HTTP request::
It is also possible to specify the raw HTTP request:
::
probe rawprobe {
# NB: \r\n automatically inserted after each string!
...
...
@@ -361,7 +370,8 @@ ACLs
----
An ACL declaration creates and initializes a named access control list
which can later be used to match client addresses::
which can later be used to match client addresses:
::
acl local {
"localhost"; // myself
...
...
@@ -375,7 +385,8 @@ if it is preceded by a negation mark, it will reject any address it is
compared to, which may not be what you intended. If the entry is
enclosed in parentheses, however, it will simply be ignored.
To match an IP address against an ACL, simply use the match operator::
To match an IP address against an ACL, simply use the match operator:
::
if (client.ip ~ local) {
return (pipe);
...
...
@@ -390,7 +401,8 @@ PCRE(3) man page.
To send flags to the PCRE engine, such as to turn on *case
insensitivity* add the flag within parens following a question mark,
like this::
like this:
::
if (req.http.host ~ "(?i)example.com$") {
...
...
...
@@ -424,7 +436,8 @@ ban_url(regex)
Subroutines
~~~~~~~~~~~
A subroutine is used to group code for legibility or reusability::
A subroutine is used to group code for legibility or reusability:
::
sub pipe_if_local {
if (client.ip ~ local) {
...
...
@@ -646,7 +659,8 @@ appear in the source.
The default versions distributed with Varnish will be implicitly
concatenated as a last resort at the end.
Example::
Example:
::
# in file "main.vcl"
include "backends.vcl";
...
...
@@ -893,7 +907,8 @@ resp.response
resp.http.header
The corresponding HTTP header.
Values may be assigned to variables using the set keyword::
Values may be assigned to variables using the set keyword:
::
sub vcl_recv {
# Normalize the Host: header
...
...
@@ -902,7 +917,8 @@ Values may be assigned to variables using the set keyword::
}
}
HTTP headers can be removed entirely using the remove keyword::
HTTP headers can be removed entirely using the remove keyword:
::
sub vcl_fetch {
# Don't cache cookies
...
...
@@ -919,7 +935,8 @@ fresh object is being generated by the backend.
The following vcl code will make Varnish serve expired objects. All
object will be kept up to two minutes past their expiration time or a
fresh object is generated.::
fresh object is generated.
::
sub vcl_recv {
set req.grace = 2m;
...
...
@@ -944,7 +961,8 @@ EXAMPLES
The following code is the equivalent of the default configuration with
the backend address set to "backend.example.com" and no backend port
specified::
specified:
::
backend default {
.host = "backend.example.com";
...
...
@@ -956,7 +974,8 @@ specified::
The following example shows how to support multiple sites running on
separate backends in the same Varnish instance, by selecting backends
based on the request URL::
based on the request URL:
::
backend www {
.host = "www.example.com";
...
...
@@ -982,7 +1001,8 @@ based on the request URL::
The following snippet demonstrates how to force a minimum TTL for
all documents. Note that this is not the same as setting the
default_ttl run-time parameter, as that only affects document for
which the backend did not specify a TTL::
which the backend did not specify a TTL:
::
import std; # needed for std.log
...
...
@@ -994,7 +1014,8 @@ which the backend did not specify a TTL::
}
The following snippet demonstrates how to force Varnish to cache
documents even when cookies are present::
documents even when cookies are present:
::
sub vcl_recv {
if (req.request == "GET" && req.http.cookie) {
...
...
@@ -1009,7 +1030,8 @@ documents even when cookies are present::
}
The following code implements the HTTP PURGE method as used by Squid
for object invalidation::
for object invalidation:
::
acl purge {
"localhost";
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment