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
7293eaf9
Commit
7293eaf9
authored
Aug 30, 2013
by
Per Buer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On virutal hosting in Varnis
parent
69369f3e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
backend_servers.rst
doc/sphinx/tutorial/backend_servers.rst
+5
-1
vcl-backends.rst
doc/sphinx/users-guide/vcl-backends.rst
+35
-0
No files found.
doc/sphinx/tutorial/backend_servers.rst
View file @
7293eaf9
...
...
@@ -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
...
...
doc/sphinx/users-guide/vcl-backends.rst
View file @
7293eaf9
...
...
@@ -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
---------
...
...
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