Commit 6b524215 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

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
parent 2a1df220
......@@ -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"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment