Thomas,

  thank you, that gets me a bit further. I have one more question though:

On 10/16/2016 12:55 AM, Thomas Lecomte wrote:
> You will need to rewrite bereq.http.host in the vcl_backend_fetch
> routine depending on the backend to which you are sending the request.

So which backend the request is sent to, has been determined in
vcl_recv, using "set req.backend_hint=somedirector".

Now I'm trying to do what you say, and in vcl_backend_fetch set the
bereq.http.host according to which backend has been selected.

I wanted to be clever and tried:

set bereq.http.host = bereq.backend.host_header;

(assuming that by the time that vcl_backend_fetch is called, the
director would already have selected a specific backend). But

"Symbol not found: 'bereq.backend.host_header' (expected type STRING)"

Then I thought ok, since the docs say about bereq.backend: "When used in
string context, returns the name of the director or backend, respectively."

I should be able to do this:

if (bereq.backend == "somedirector")
{
   set bereq.http.host = "somehost";
}
elsif (bereq.backend == "otherdirector")
{
   set bereq.http.host= "otherhost";
}

But

          (VRT_r_bereq_backend(ctx) == "somedirector")
                                    ^
vgc.c:2152:35: error: comparison with string literal results in
unspecified behavior [-Werror=address]

How can I force the "string context" on the backend/director, so that I
can use string comparison to find out which backend has been selected?
Or how can I otherwise compare bereq.backend with something?

I also tried to access the req.backend_hint but that seems to be
write-only. If all else files I could maybe abuse some otherwise unused
variable in the "req" object that I can set in vcl_recv (where I
determine which backend I want) and then read in vcl_backend_fetch?

I guess it's probably all dead simple and I just didn't find it.

Bye
Frederik

-- 
Frederik Ramm  ##  eMail frede...@remote.org  ##  N49°00'09" E008°23'33"

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to