Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
7f501a1c
Commit
7f501a1c
authored
Mar 07, 2013
by
Per Buer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Examples are back
parent
da7d47ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
0 deletions
+94
-0
vcl-example-acls.rst
doc/sphinx/users-guide/vcl-example-acls.rst
+34
-0
vcl-example-manipulating-headers.rst
doc/sphinx/users-guide/vcl-example-manipulating-headers.rst
+21
-0
vcl-example-manipulating-responses.rst
...sphinx/users-guide/vcl-example-manipulating-responses.rst
+19
-0
vcl-example-websockets.rst
doc/sphinx/users-guide/vcl-example-websockets.rst
+20
-0
No files found.
doc/sphinx/users-guide/vcl-example-acls.rst
0 → 100644
View file @
7f501a1c
ACLs
~~~~
You create a named access control list with the *acl* keyword. You can match
the IP address of the client against an ACL with the match operator.::
# Who is allowed to purge....
acl local {
"localhost";
"192.168.1.0"/24; /* and everyone on the local network */
! "192.168.1.23"; /* except for the dialin router */
}
sub vcl_recv {
if (req.method == "PURGE") {
if (client.ip ~ local) {
return(lookup);
}
}
}
sub vcl_hit {
if (req.method == "PURGE") {
set obj.ttl = 0s;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.method == "PURGE") {
error 404 "Not in cache.";
}
}
doc/sphinx/users-guide/vcl-example-manipulating-headers.rst
0 → 100644
View file @
7f501a1c
Manipulating request headers in VCL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lets say we want to remove the cookie for all objects in the /images
directory of our web server::
sub vcl_recv {
if (req.url ~ "^/images") {
unset req.http.cookie;
}
}
Now, when the request is handled to the backend server there will be
no cookie header. The interesting line is the one with the
if-statement. It matches the URL, taken from the request object, and
matches it against the regular expression. Note the match operator. If
it matches the Cookie: header of the request is unset (deleted).
doc/sphinx/users-guide/vcl-example-manipulating-responses.rst
0 → 100644
View file @
7f501a1c
Altering the backend response
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here we override the TTL of a object comming from the backend if it
matches certain criteria::
sub vcl_fetch {
if (req.url ~ "\.(png|gif|jpg)$") {
unset beresp.http.set-cookie;
set beresp.ttl = 1h;
}
}
.. XXX ref hit-for-pass
We also remove any Set-Cookie headers in order to avoid a hit-for-pass
object to be created.
doc/sphinx/users-guide/vcl-example-websockets.rst
0 → 100644
View file @
7f501a1c
Implementing websocket support
------------------------------
Websockets is a technology for creating a bidirectional stream-based channel over HTTP.
To run websockets through Varnish you need to pipe it, and copy the Upgrade header. Use the following
VCL config to do so::
sub vcl_pipe {
if (req.http.upgrade) {
set bereq.http.upgrade = req.http.upgrade;
}
}
sub vcl_recv {
if (req.http.Upgrade ~ "(?i)websocket") {
return (pipe);
}
}
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