Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible for Varnish to parse the hostname to determine which backend to use? I'd like to avoid having to do:

if (url = 'backend1') {
    set req.backend = backend1;

.. for all of them.

I'd like to be able to do something like this:

set req.backend = regsub(req.http.Host, "^.*([^.]+)\.mydomain\.com$", "\1");

.. but that doesn't work.

share|improve this question
up vote 1 down vote accepted

No, that is not possible at the moment. You could use build scripts that build your varnish configuration automatically. The varnish developers are thinking about dynamic backend declaration possibilites, which would cover your use case. The dev is asking for comapnies that would use this feature, so you maybe want to tell him that you are interested ;-)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.