Sent from my Galaxy Tab A (2016)-------- Original message --------From: 
[email protected] Date: 9/10/2019  12:38 PM  (GMT+05:45) 
To: [email protected] Subject: varnish-misc Digest, Vol 160, Issue 
3 Send varnish-misc mailing list submissions to   
[email protected] subscribe or unsubscribe via the World Wide 
Web, visit https://www.varnish-cache.org/lists/mailman/listinfo/varnish-miscor, 
via email, send a message with subject or body 'help' to   
[email protected] can reach the person managing the 
list at     [email protected] replying, please edit your 
Subject line so it is more specificthan "Re: Contents of varnish-misc 
digest..."Today's Topics:   1. Re: Environment variables in VCL (Bender, 
Charles)   2. Re: Environment variables in VCL (Guillaume Quintard)   3. Re: 
Environment variables in VCL (Poul-Henning Kamp)   4. Re: Environment variables 
in VCL (Guillaume 
Quintard)----------------------------------------------------------------------Message:
 1Date: Tue, 10 Sep 2019 00:15:42 +0000From: "Bender, Charles" 
<[email protected]>To: Hugues Alary <[email protected]>, varnish-misc  
<[email protected]>Subject: Re: Environment variables in 
VCLMessage-ID: 
<[email protected]>Content-Type: text/plain; 
charset="utf-8"Looking at a VCL I use to set hostname and this seems to 
work-sub vcl_deliver {  set resp.http.X-Cache-Node = server.hostname;}Maybe you 
can use in form of server.environmental_variableFrom: varnish-misc 
<[email protected]> on behalf of 
Hugues Alary <[email protected]>Date: Monday, September 9, 2019 at 6:09 
PMTo: varnish-misc <[email protected]>Subject: Environment 
variables in VCLHi there,I'm using Varnish in a Kubernetes cluster and my 
configuration needs to use environment variables.More specifically, I'm trying 
to declare a `backend` with a `.host` whose value is an environment 
variable.backend b0 {  .host = "$ENVIRONMENT_VARIABLE_HOSTNAME";  .port = "80"; 
 .connect_timeout = 300s;  .first_byte_timeout = 300s;  .between_bytes_timeout 
= 300s;}This doesn't work. It tried using the std.get_env() function but it 
doesn't work in this context.Is there any way to use environment variables in 
VCL, or do I have to create a configuration template?Thanks for your 
help,Cheers,-Hugues-------------- next part --------------An HTML attachment 
was scrubbed...URL: 
<https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20190910/672db2ce/attachment-0001.html>------------------------------Message:
 2Date: Tue, 10 Sep 2019 07:38:44 +0200From: Guillaume Quintard 
<[email protected]>To: "Bender, Charles" 
<[email protected]>Cc: Hugues Alary <[email protected]>, varnish-misc  
<[email protected]>Subject: Re: Environment variables in 
VCLMessage-ID:    
<caj6zyqy5rnbjfcs88re6-hmfsqvyuzbokhoofq_c+suqnrq...@mail.gmail.com>Content-Type:
 text/plain; charset="utf-8"Hi,The trouble is that the backends are C 
structures created when you compilethe VCL, but std.getenv() is called when you 
use the compile VCL, so thatway too late.I see two ways:- use a dynamic backend 
vmod (like vmod_goto), allowing you to regularlyinterrogate DNS a build an 
elastic director- create a static backend point to you k8s proxy, and just 
setreq.http.host to whatever value you want.The last one is two of course 
create a template, but remember that varnishresolves domain names in static 
backend when it compiles the VCL, so theresolved IP may not be right all the 
time.-- Guillaume QuintardOn Tue, Sep 10, 2019 at 2:17 AM Bender, Charles 
<[email protected]>wrote:> Looking at a VCL I use to set hostname and 
this seems to work->>>> sub vcl_deliver {>>   set resp.http.X-Cache-Node = 
server.hostname;>> }>>>> Maybe you can use in form of 
server.environmental_variable>>>> *From: *varnish-misc 
<varnish-misc-bounces+charles=> [email protected]> on behalf of 
Hugues Alary <> [email protected]>> *Date: *Monday, September 9, 2019 at 
6:09 PM> *To: *varnish-misc <[email protected]>> *Subject: 
*Environment variables in VCL>>>> Hi there,>>>> I'm using Varnish in a 
Kubernetes cluster and my configuration needs to> use environment 
variables.>>>> More specifically, I'm trying to declare a `backend` with a 
`.host` whose> value is an environment variable.>>> backend b0 {>   .host = 
"*$ENVIRONMENT_VARIABLE_HOSTNAME*";>   .port = "80";>   .connect_timeout = 
300s;>   .first_byte_timeout = 300s;>   .between_bytes_timeout = 300s;>> }>>>> 
This doesn't work. It tried using the std.get_env() function but it> doesn't 
work in this context.>>>> *Is there any way to use environment variables in 
VCL, or do I have to> create a configuration template?*>>>> Thanks for your 
help,>>>> Cheers,>> -Hugues>>> _______________________________________________> 
varnish-misc mailing list> [email protected]> 
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/15f9a551/attachment-0001.html>------------------------------Message:
 3Date: Tue, 10 Sep 2019 06:44:45 +0000From: "Poul-Henning Kamp" 
<[email protected]>To: Guillaume Quintard <[email protected]>Cc: 
"Bender, Charles" <[email protected]>, varnish-misc     
<[email protected]>Subject: Re: Environment variables in 
VCLMessage-ID: <[email protected]>Content-Type: text/plain; 
charset="us-ascii"--------In message 
<caj6zyqy5rnbjfcs88re6-hmfsqvyuzbokhoofq_c+suqnrq...@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.vclThen in VCL: 
backend b0 {            .host = include "/somewhere/hostname.vcl" ;             
.port 80                ...-- Poul-Henning Kamp       | UNIX since Zilog Zeus 
[email protected]         | TCP/IP since RFC 956FreeBSD committer       | BSD 
since 4.3-tahoe    Never attribute to malice what can adequately be explained 
by incompetence.------------------------------Message: 4Date: Tue, 10 Sep 2019 
08:52:53 +0200From: Guillaume Quintard <[email protected]>To: 
Poul-Henning Kamp <[email protected]>Cc: "Bender, Charles" 
<[email protected]>, varnish-misc      
<[email protected]>Subject: Re: Environment variables in 
VCLMessage-ID:    
<caj6zyqzhdbagqwzvmbdbs7uos+sy+0bnucyajn3fvpxbqkf...@mail.gmail.com>Content-Type:
 text/plain; charset="utf-8"True, but that amounts to template processing :-)-- 
Guillaume QuintardOn Tue, Sep 10, 2019 at 8:44 AM Poul-Henning Kamp 
<[email protected]>wrote:> --------> In message <> 
caj6zyqy5rnbjfcs88re6-hmfsqvyuzbokhoofq_c+suqnrq...@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> [email protected]         | TCP/IP since RFC 956> 
FreeBSD committer       | BSD since 4.3-tahoe> Never attribute to malice what 
can adequately be explained by incompetence.>-------------- next part 
--------------An HTML attachment was scrubbed...URL: 
<https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20190910/9d6ef430/attachment.html>------------------------------Subject:
 Digest Footer_______________________________________________varnish-misc 
mailing 
[email protected]https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc------------------------------End
 of varnish-misc Digest, Vol 160, Issue 
3********************************************
_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to