[master] 6b52421 Set a better example in the docs
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Nov 30 17:01:05 CET 2016
commit 6b5242150f3e0a485c8e83d1fe1c4491acdc8105
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed Nov 30 15:14:03 2016 +0100
Set a better example in the docs
Adapted from an original patch from @michbsd: on top of normalizing the
host header we now have a regular expressions that only match the right
domains and potential sub-domains.
Closes #2140
diff --git a/doc/sphinx/users-guide/vcl-separate.rst b/doc/sphinx/users-guide/vcl-separate.rst
index 67c9727..031807c 100644
--- a/doc/sphinx/users-guide/vcl-separate.rst
+++ b/doc/sphinx/users-guide/vcl-separate.rst
@@ -28,14 +28,19 @@ Next we write the top-level VCL program, which branches out
to the other two, depending on the Host: header in the
request::
- /* We have to have a backend, even if we do not use it */
+ import std;
+
+ # We have to have a backend, even if we do not use it
backend default { .host = "127.0.0.1"; }
sub vcl_recv {
- if (req.http.host ~ "varnish.org$") {
+ # Normalize host header
+ set req.http.host = std.tolower(req.http.host);
+
+ if (req.http.host ~ "\.?varnish\.org$") {
return (vcl(l_vo));
}
- if (req.http.host ~ "varnish-cache.org$") {
+ if (req.http.host ~ "\.?varnish-cache\.org$") {
return (vcl(l_vc));
}
return (synth(302, "http://varnish-cache.org"));
More information about the varnish-commit
mailing list