Environment variables in VCL

Hugues Alary hugues at betabrand.com
Tue Sep 10 19:13:03 UTC 2019


Guillaume, Poul-Henning, thank you for your suggestions.

Regarding,
> - create a static backend point to you k8s proxy, and just set
req.http.host to whatever value you want.

I don't think this would work for me since I'm working with a backend
definition, trying to change the IP address (/hostname) to which the
backend points to and not simply trying to change the Host header of the
request.

Cheers,
-Hugues



On Mon, Sep 9, 2019 at 11:54 PM Guillaume Quintard <
guillaume at varnish-software.com> wrote:

> True, but that amounts to template processing :-)
>
> --
> Guillaume Quintard
>
>
> On Tue, Sep 10, 2019 at 8:44 AM Poul-Henning Kamp <phk at phk.freebsd.dk>
> wrote:
>
>> --------
>> In message <
>> CAJ6ZYQy5RnBjfCs88re6-hMfsQvyuzbOkHoofQ_c+suQNRQjig at mail.gmail.com>
>> , Guillaume Quintard writes:
>>
>> >I see two ways:
>>
>> There is a third way:
>>
>> You can use:
>>
>>         include "somefile"
>>
>> anywhere and everywhere in a VCL program.
>>
>> Before you start your varnishd, do this in a shell script:
>>
>>         echo "\"$ENVIRONMENT_VARIABLE_HOSTNAME\"" >
>> /somewhere/hostname.vcl
>>
>> Then in VCL:
>>
>>         backend b0 {
>>                 .host = include "/somewhere/hostname.vcl" ;
>>                 .port 80
>>                 ...
>>
>>
>>
>> --
>> Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
>> phk at FreeBSD.ORG         | TCP/IP since RFC 956
>> FreeBSD committer       | BSD since 4.3-tahoe
>> Never attribute to malice what can adequately be explained by
>> incompetence.
>>
> _______________________________________________
> 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/20190910/b4458dbd/attachment.html>


More information about the varnish-misc mailing list