Reg: backend 'name' in VCL before going to origin
Hardik
hetardik.p at gmail.com
Fri May 31 08:47:06 UTC 2019
Hi Guillaume,
There shard algorithm is used for director. That's why it is working. I
tried same and able to get exact backend name in v_b_f.
new di_utc_0 = directors.shard();
di_utc_0.add_backend(be_utc_16);
di_utc_0.reconfigure();
But I can not use shard algorithm as requirement is to use fallback/nearest.
I understood your point that currently no function call available which can
provide exact backend.
Still if any work around for this then please let me know. It is really
required.
Thank you
Hardik
On Thu, 30 May 2019 at 22:48, Guillaume Quintard <
guillaume at varnish-software.com> wrote:
> Why not share it? I might be missing something.
> --
> Guillaume Quintard
>
>
> On Thu, May 30, 2019 at 10:10 AM Hardik <hetardik.p at gmail.com> wrote:
>
>> Hi Guillaume
>>
>> Ok..!
>>
>> Today I saw one VCL where it was resolving actual backend from director
>> in miss/pass function. I have not tried it. Will let you know how it
>> goes..
>>
>> Thank you
>> Hardik
>>
>> On Thu, 30 May 2019, 22:23 Guillaume Quintard, <
>> guillaume at varnish-software.com> wrote:
>>
>>> Hi,
>>>
>>> Getting the resolved backend in v_b_f won't be possible until
>>> https://github.com/varnishcache/varnish-cache/pull/2680 gets merge. In
>>> the meantime (unless you write the vmod for it), there's no way to
>>> pre-resolve the director.
>>>
>>> --
>>> Guillaume Quintard
>>>
>>>
>>> On Wed, May 29, 2019 at 6:26 PM Hardik <hetardik.p at gmail.com> wrote:
>>>
>>>> Thanks Guillaume.
>>>>
>>>> I am already using bereq.backend in v_b_f which is giving director
>>>> name. As you have pointed out, I want 'exact' backend name inside
>>>> director. Also before sending to origin because want to set few headers
>>>> for origin as per exact backend.
>>>>
>>>> On Thu, 30 May 2019, 04:20 Guillaume Quintard, <
>>>> guillaume at varnish-software.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> man vcl is your friend. I believe what you want is "bereq.backend"
>>>>>
>>>>> Also, you could just write: std.log("using backend: " + bereq.backend)
>>>>>
>>>>> note that bereq.backend will return the unresolved backend, meaning
>>>>> that if backends are inside a director, you'll get the name of the
>>>>> director, since the backend choice happens between v_b_f and v_b_r. To know
>>>>> what exact backend was used, you have to check in v_b_r.
>>>>>
>>>>> cheers,
>>>>> --
>>>>> Guillaume Quintard
>>>>>
>>>>>
>>>>> On Wed, May 29, 2019 at 4:56 AM Hardik <hetardik.p at gmail.com> wrote:
>>>>>
>>>>>> Hi Team,
>>>>>>
>>>>>> Requirement : *to set few headers based on backend origin ( having
>>>>>> multiple origins/backends in single director)*.
>>>>>>
>>>>>> I want to do similar to this.
>>>>>> https://stackoverflow.com/questions/43357690/varnish-vcl-how-can-i-switch-on-req-backend-hint
>>>>>>
>>>>>> sub vcl_backend_fetch {
>>>>>> if (bereq.backend.name == "one") {
>>>>>> std.log("one");
>>>>>> } else if (bereq.backend.name == "two") {
>>>>>> std.log("two");
>>>>>> } else {
>>>>>> std.log("neither one");
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> I am trying to do same (inside b_fetch) but getting error that symbol
>>>>>> not found. I am using varnish 6.1.
>>>>>> Is this different function call/name for varnish 6.1 ?
>>>>>>
>>>>>> Thank you
>>>>>> Hardik
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> varnish-misc mailing list
>>>>>> varnish-misc at varnish-cache.org
>>>>>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>>>>>>
>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20190531/07083d2f/attachment-0001.html>
More information about the varnish-misc
mailing list