Commit 7293eaf9 authored by Per Buer's avatar Per Buer

On virutal hosting in Varnis

parent 69369f3e
......@@ -20,19 +20,23 @@ the configuration that looks like this:::
.port = "80";
}
This means we set up a backend in Varnish that fetches content from
the host www.varnish-cache.org on port 80.
Since you probably don't want to be mirroring varnish-cache.org we
need to get Varnish to fetch content from your own origin
server. We've already bound Varnish to the public port 80 on the
server so now we need to tie it to the origin.
For this example, let's pretend the origin server is running on
localhost, port 8080.
localhost, port 8080.::
backend default {
.host = "127.0.0.1";
.port = "8080";
}
Varnish can have several backends defined and can you can even join
several backends together into clusters of backends for load balancing
purposes, having Varnish pick one backend based on different
......
......@@ -31,6 +31,7 @@ Varnish can have several backends defined and can you can even join
several backends together into clusters of backends for load balancing
purposes.
Multiple backends
-----------------
......@@ -73,8 +74,42 @@ really arbitrary data. You want to send mobile devices to a different
backend? No problem. if (req.User-agent ~ /mobile/) .. should do the
trick.
Backends and virtual hosts in Varnish
-------------------------------------
Varnish fully supports virtual hosts. They might work in a somewhat
counter intuitive fashion since they are never declared
explicitly. You set up the routing of incoming HTTP requests in
vcl_recv. If you want this routing to be done on the basis of virtual
hosts you just need to inspect req.http.host.
You can have something like this:::
sub vcl_recv {
if (req.http.host ~ "foo.com") {
set req.backend = foo;
} elsif (req.http.host ~ "bar.com") {
set req.backend = bar;
}
}
Note that the first regular expressions will match foo.com,
www.foo.com, zoop.foo.com and any other host ending in foo.com. In
this example this is intentional but you might want it to be a bit
more tight, maybe relying on the == operator in stead, like this:::
sub vcl_recv {
if (req.http.host == "foo.com" or req.http.host == "www.foo.com") {
set req.backend = foo;
}
}
.. _users-guide-advanced_backend_servers-directors:
Directors
---------
......
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