From cristian.c at istream.today Wed Sep 4 07:39:51 2019 From: cristian.c at istream.today (cristian.c at istream.today) Date: Wed, 4 Sep 2019 10:39:51 +0300 Subject: Wordpress recommendation Message-ID: <016001d562f3$f02e2a70$d08a7f50$@istream.today> Hello, Can I get some recommendation for wordpress? Like what are the best methods to cache wordpress. Thank you! Cristian -------------- next part -------------- An HTML attachment was scrubbed... URL: From guillaume at varnish-software.com Wed Sep 4 08:02:18 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Wed, 4 Sep 2019 17:02:18 +0900 Subject: Wordpress recommendation In-Reply-To: <016001d562f3$f02e2a70$d08a7f50$@istream.today> References: <016001d562f3$f02e2a70$d08a7f50$@istream.today> Message-ID: did you have a look at this https://codex.wordpress.org/Varnish ? -- Guillaume Quintard On Wed, Sep 4, 2019 at 4:40 PM wrote: > Hello, > > > > Can I get some recommendation for wordpress? Like what are the best > methods to cache wordpress. > > > > > > Thank you! > > Cristian > _______________________________________________ > 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: From cristian.c at istream.today Wed Sep 4 08:15:04 2019 From: cristian.c at istream.today (Cristian Ciobanu) Date: Wed, 4 Sep 2019 11:15:04 +0300 Subject: Wordpress recommendation In-Reply-To: References: <016001d562f3$f02e2a70$d08a7f50$@istream.today> Message-ID: Thank you very much! On Wed, 4 Sep 2019, 11:02 Guillaume Quintard, < guillaume at varnish-software.com> wrote: > did you have a look at this https://codex.wordpress.org/Varnish ? > -- > Guillaume Quintard > > > On Wed, Sep 4, 2019 at 4:40 PM wrote: > >> Hello, >> >> >> >> Can I get some recommendation for wordpress? Like what are the best >> methods to cache wordpress. >> >> >> >> >> >> Thank you! >> >> Cristian >> _______________________________________________ >> 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: From guillaume at varnish-software.com Mon Sep 9 06:27:31 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Mon, 9 Sep 2019 08:27:31 +0200 Subject: =?UTF-8?Q?Re=3A_synth_response_body_not_working=E2=80=A6?= In-Reply-To: References: <75e61b87-8c43-4992-9a07-b9be6872cc4f@Spark> <308cb625-999e-43dc-bd3d-06cf10484b44@Spark> Message-ID: please keep the mailing-list in the loop -- Guillaume Quintard On Tue, Sep 3, 2019 at 2:51 PM Tim Kelty wrote: > Thanks Guillaume, > > Makes sense about bypassing the built-in synth?and the 0-length body. > Looking at the first line of the response, I can see something like this > (still no reason after 200): > > ? curl -I -X "PURGE" -H "XKEY-PURGE:el30" https://site.com > HTTP/2 200 > accept-ranges: bytes > date: Tue, 03 Sep 2019 12:33:14 GMT > server: Varnish > x-varnish: 721122 > content-length: 0 > > > So what should I return to include the reason in the response? > I think my vcl_synth example came from: > https://github.com/mattiasgeniar/varnish-5.0-configuration-templates/blob/master/default.vcl#L381-L397 > > Thanks again for the help! > > ? > Tim Kelty > On Aug 29, 2019, 3:18 PM -0400, Guillaume Quintard < > guillaume at varnish-software.com>, wrote: > > because you return deliver, you are bypassing the builtin.vcl section that > usually calls synthetic() ( > https://github.com/varnishcache/varnish-cache/blob/master/bin/varnishd/builtin.vcl#L113), > that is why you have a 0-length body. > > Also, the "Invalidated..." message is the reason (like the "OK" for a > 200), not the body. Check the response line of your response (i.e. the > first line, before the headers) > > -- > Guillaume Quintard > > > On Thu, Aug 29, 2019 at 11:38 AM Tim Kelty wrote: > > Within my vcl_recv, I have something like this: > > > # Allow purging > if (req.method == "PURGE") { > if (!client.ip ~ purge) { > return (synth(403, "Forbidden")); > } > > if (req.http.xkey-purge) { > set req.http.n-gone = xkey.purge(req.http.xkey-purge); > # If you got this stage (and didn't error out above), purge the cached > result > return (synth(200, "Invalidated "+req.http.n-gone+" objects")); > } else { > return (purge); > } > > } > > ?and a a vcl_synth like: > > sub vcl_synth { > if (resp.status == 720) { > # We use this special error status 720 to force redirects with 301 > (permanent) redirects > # To use this, call the following from anywhere in vcl_recv: return > (synth(720, "http://host/new.html")); > set resp.http.Location = resp.reason; > set resp.status = 301; > return (deliver); > } elseif (resp.status == 721) { > # And we use error status 721 to force redirects with a 302 (temporary) > redirect > # To use this, call the following from anywhere in vcl_recv: return > (synth(720, "http://host/new.html")); > set resp.http.Location = resp.reason; > set resp.status = 302; > return (deliver); > } > > return (deliver); > } > > > When I perform the xkey-purge request, I get back a 200, and can confirm > that the purging is working, but the content-length is always 0 (I don't > get the "Invalidated n objects" message). > > Not sure where to start debugging?any idea what could cause this? > > ? > Tim Kelty > _______________________________________________ > 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: From hugues at betabrand.com Mon Sep 9 22:06:51 2019 From: hugues at betabrand.com (Hugues Alary) Date: Mon, 9 Sep 2019 15:06:51 -0700 Subject: Environment variables in VCL Message-ID: 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From charles at beachcamera.com Tue Sep 10 00:15:42 2019 From: charles at beachcamera.com (Bender, Charles) Date: Tue, 10 Sep 2019 00:15:42 +0000 Subject: Environment variables in VCL In-Reply-To: References: Message-ID: 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 on behalf of Hugues Alary Date: Monday, September 9, 2019 at 6:09 PM To: varnish-misc 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From guillaume at varnish-software.com Tue Sep 10 05:38:44 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 10 Sep 2019 07:38:44 +0200 Subject: Environment variables in VCL In-Reply-To: References: Message-ID: Hi, The trouble is that the backends are C structures created when you compile the VCL, but std.getenv() is called when you use the compile VCL, so that way too late. I see two ways: - use a dynamic backend vmod (like vmod_goto), allowing you to regularly interrogate DNS a build an elastic director - create a static backend point to you k8s proxy, and just set req.http.host to whatever value you want. The last one is two of course create a template, but remember that varnish resolves domain names in static backend when it compiles the VCL, so the resolved IP may not be right all the time. -- Guillaume Quintard On Tue, Sep 10, 2019 at 2:17 AM Bender, Charles 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 beachcamera.com at varnish-cache.org> on behalf of Hugues Alary < > hugues at betabrand.com> > *Date: *Monday, September 9, 2019 at 6:09 PM > *To: *varnish-misc > *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 > varnish-misc at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc > -------------- next part -------------- An HTML attachment was scrubbed... URL: From phk at phk.freebsd.dk Tue Sep 10 06:44:45 2019 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue, 10 Sep 2019 06:44:45 +0000 Subject: Environment variables in VCL In-Reply-To: References: Message-ID: <14936.1568097885@critter.freebsd.dk> -------- In message , 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. From guillaume at varnish-software.com Tue Sep 10 06:52:53 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 10 Sep 2019 08:52:53 +0200 Subject: Environment variables in VCL In-Reply-To: <14936.1568097885@critter.freebsd.dk> References: <14936.1568097885@critter.freebsd.dk> Message-ID: True, but that amounts to template processing :-) -- Guillaume Quintard On Tue, Sep 10, 2019 at 8:44 AM Poul-Henning Kamp 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. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hugues at betabrand.com Tue Sep 10 19:13:03 2019 From: hugues at betabrand.com (Hugues Alary) Date: Tue, 10 Sep 2019 12:13:03 -0700 Subject: Environment variables in VCL In-Reply-To: References: <14936.1568097885@critter.freebsd.dk> Message-ID: 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 > 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: From vlad.rusu at lola.tech Tue Sep 10 20:54:57 2019 From: vlad.rusu at lola.tech (Vlad Rusu) Date: Tue, 10 Sep 2019 23:54:57 +0300 Subject: Environment variables in VCL In-Reply-To: References: <14936.1568097885@critter.freebsd.dk> Message-ID: @Hugues I am also a heavy user in kube/openshift environments and this issue is addressed by means of templating. Using tools like helm would easily solve this for you. Helm has the value and it uses it when rendering the backends file - in the form of a configmap perhaps. If you can?t/don?t want to use helm, you can still ?render? configuration by consuming values from the ENV by using envsubst for example. This is how we dis it before helm. Burn the backends.vcl file AT RUNTIME by passing the backends.vcl file through envsubst. Either way, my recommendation is to solve this through templating and not by trying to access ENV directly from the the backends VCL. I?m saying this having a proper SDLC in mind. Of course, dynamic backends and all other options Guillaume and Paul-Henning have mentioned are solid. Vlad Rusu On Tue, 10 Sep 2019 at 22:14, Hugues Alary wrote: > 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 >> 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 >> > _______________________________________________ > varnish-misc mailing list > varnish-misc at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc > -- Sent from my iPhone -------------- next part -------------- An HTML attachment was scrubbed... URL: From hugues at betabrand.com Tue Sep 10 22:03:08 2019 From: hugues at betabrand.com (Hugues Alary) Date: Tue, 10 Sep 2019 15:03:08 -0700 Subject: Environment variables in VCL In-Reply-To: References: <14936.1568097885@critter.freebsd.dk> Message-ID: Hi Vlad, Thanks for the suggestion. I was using Helm and I'm actually running into this issue because I'm migrating away from Helm to use Kustomize. Using `envsubst` is what I set out to do in the end! I'm not a fan of having to add an init container just for templating, but ???????. Cheers, -Hugues On Tue, Sep 10, 2019 at 1:55 PM Vlad Rusu wrote: > @Hugues > > I am also a heavy user in kube/openshift environments and this issue is > addressed by means of templating. > > Using tools like helm would easily solve this for you. Helm has the value > and it uses it when rendering the backends file - in the form of a > configmap perhaps. > > If you can?t/don?t want to use helm, you can still ?render? configuration > by consuming values from the ENV by using envsubst for example. This is how > we dis it before helm. Burn the backends.vcl file AT RUNTIME by passing the > backends.vcl file through envsubst. > > Either way, my recommendation is to solve this through templating and not > by trying to access ENV directly from the the backends VCL. I?m saying this > having a proper SDLC in mind. > > Of course, dynamic backends and all other options Guillaume and > Paul-Henning have mentioned are solid. > > Vlad Rusu > > On Tue, 10 Sep 2019 at 22:14, Hugues Alary wrote: > >> 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 >>> 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 >>> >> _______________________________________________ >> varnish-misc mailing list >> varnish-misc at varnish-cache.org >> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc >> > -- > Sent from my iPhone > -------------- next part -------------- An HTML attachment was scrubbed... URL: From balghi at gmail.com Sat Sep 14 03:44:59 2019 From: balghi at gmail.com (balghi) Date: Sat, 14 Sep 2019 09:29:59 +0545 Subject: varnish-misc Digest, Vol 160, Issue 3 Message-ID: <21qsdhdo3bs5spdu85u8wktb.1568432699787@email.android.com> Sent from my Galaxy Tab A (2016)-------- Original message --------From: varnish-misc-request at varnish-cache.org Date: 9/10/2019 12:38 PM (GMT+05:45) To: varnish-misc at varnish-cache.org Subject: varnish-misc Digest, Vol 160, Issue 3 Send varnish-misc mailing list submissions to varnish-misc at varnish-cache.orgTo 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 varnish-misc-request at varnish-cache.orgYou can reach the person managing the list at varnish-misc-owner at varnish-cache.orgWhen 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" To: Hugues Alary , varnish-misc Subject: Re: Environment variables in VCLMessage-ID: 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 on behalf of Hugues Alary Date: Monday, September 9, 2019 at 6:09 PMTo: varnish-misc 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: ------------------------------Message: 2Date: Tue, 10 Sep 2019 07:38:44 +0200From: Guillaume Quintard To: "Bender, Charles" Cc: Hugues Alary , varnish-misc Subject: Re: Environment variables in VCLMessage-ID: 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 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 beachcamera.com at varnish-cache.org> on behalf of Hugues Alary <> hugues at betabrand.com>> *Date: *Monday, September 9, 2019 at 6:09 PM> *To: *varnish-misc > *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> varnish-misc at varnish-cache.org> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc>-------------- next part --------------An HTML attachment was scrubbed...URL: ------------------------------Message: 3Date: Tue, 10 Sep 2019 06:44:45 +0000From: "Poul-Henning Kamp" To: Guillaume Quintard Cc: "Bender, Charles" , varnish-misc Subject: Re: Environment variables in VCLMessage-ID: <14936.1568097885 at critter.freebsd.dk>Content-Type: text/plain; charset="us-ascii"--------In message , 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 3.20phk at FreeBSD.ORG???????? | 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 To: Poul-Henning Kamp Cc: "Bender, Charles" , varnish-misc Subject: Re: Environment variables in VCLMessage-ID: 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 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.>-------------- next part --------------An HTML attachment was scrubbed...URL: ------------------------------Subject: Digest Footer_______________________________________________varnish-misc mailing listvarnish-misc at varnish-cache.orghttps://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc------------------------------End of varnish-misc Digest, Vol 160, Issue 3******************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From ciapnz at gmail.com Sat Sep 14 22:17:51 2019 From: ciapnz at gmail.com (Danila Vershinin) Date: Sun, 15 Sep 2019 01:17:51 +0300 Subject: Serve cached object without assembling ESI? Message-ID: Hi, I'm trying to understand whether it's feasible to build a CDN of Varnish instances, whose primary origin(backend) is a Varnish instance which processes an ESI-capable app. So basically: USA visitor -> Varnish USA -> Varnish primary -> THE APP with ESI blocks RUS visitor -> Varnish RUS -> Varnish primary -> THE APP with ESI blocks CAN -> Varnish primary -> THE APP with ESI blocks The APP emits HTML with ESI tags for different blocks, and sure enough, those have different cache policies. If a request arrives to an edge Varnish, I want it to talk to the primary Varnish (so as to cache on the edge against a primary cache), but this "Varnish primary" serves the content with ESI already assembled. Thus there is no telling, how long we should cache that full page HTML on the edges. Q: Is there a magic way to instruct the primary Varnish to not do ESI processing on the content that was already cached ?? Meaning keep things as usual if request arrives directly to primary Varnish (ESI on), but receive non-assembled HTML (with esi tags inside) otherwise, so that edges can do assembling themselves, and thus cache things on the edge with proper TTLs for blocks. Or I just have to resort to completely disabling do_esi on the primary server? Which I could do, but that must mean that the primary Varnish cannot serve visitors directly (= loosing the edge location with lowest latency to nearby users). -------------- next part -------------- An HTML attachment was scrubbed... URL: From guillaume at varnish-software.com Sun Sep 15 06:28:41 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sun, 15 Sep 2019 08:28:41 +0200 Subject: Serve cached object without assembling ESI? In-Reply-To: References: Message-ID: Hi Danila, Check "man vcl", specifically beresp.do_esi and resp.do_esi. >From what I understand, you want to always enable the former, and only enable the latter conditionally. For example, the edges could add a header "varnish-edge-token" to their request to the primary varnish, and you could have that VCL there: sub vcl_deliver { if (req.http.varnish-edge-token == "MYTOKEN") { set resp.do_esi = false; } } Should be fairly straightforward. Cheers, -- Guillaume Quintard On Sun, Sep 15, 2019 at 12:19 AM Danila Vershinin wrote: > Hi, > > I'm trying to understand whether it's feasible to build a CDN of Varnish > instances, whose primary origin(backend) is a Varnish instance which > processes an ESI-capable app. > > So basically: > > USA visitor -> Varnish USA -> Varnish primary -> THE APP with ESI blocks > RUS visitor -> Varnish RUS -> Varnish primary -> THE APP with ESI blocks > CAN -> Varnish primary -> THE APP with ESI blocks > > The APP emits HTML with ESI tags for different blocks, and sure enough, > those have different cache policies. > If a request arrives to an edge Varnish, I want it to talk to the primary > Varnish (so as to cache on the edge against a primary cache), but this > "Varnish primary" serves the content with ESI already assembled. Thus there > is no telling, how long we should cache that full page HTML on the edges. > > Q: Is there a magic way to instruct the primary Varnish to not do ESI > processing on the content that was *already cached* ?? > Meaning keep things as usual if request arrives directly to primary > Varnish (ESI on), but receive non-assembled HTML (with esi tags inside) > otherwise, so that edges can do assembling themselves, and thus cache > things on the edge with proper TTLs for blocks. > > Or I just have to resort to completely disabling do_esi on the primary > server? Which I could do, but that must mean that the primary Varnish > cannot serve visitors directly (= loosing the edge location with lowest > latency to nearby users). > > _______________________________________________ > 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: From ciapnz at gmail.com Mon Sep 16 07:36:32 2019 From: ciapnz at gmail.com (Danila Vershinin) Date: Mon, 16 Sep 2019 10:36:32 +0300 Subject: Serve cached object without assembling ESI? In-Reply-To: References: Message-ID: <34832405-D63C-4F4F-9252-6B24C461EC6B@gmail.com> Thank you very much. Sent from my iPhone > On 15 Sep 2019, at 09:28, Guillaume Quintard wrote: > > Hi Danila, > > Check "man vcl", specifically beresp.do_esi and resp.do_esi. > > From what I understand, you want to always enable the former, and only enable the latter conditionally. For example, the edges could add a header "varnish-edge-token" to their request to the primary varnish, and you could have that VCL there: > > sub vcl_deliver { > if (req.http.varnish-edge-token == "MYTOKEN") { > set resp.do_esi = false; > } > } > > Should be fairly straightforward. > > Cheers, > > -- > Guillaume Quintard > > >> On Sun, Sep 15, 2019 at 12:19 AM Danila Vershinin wrote: >> Hi, >> >> I'm trying to understand whether it's feasible to build a CDN of Varnish instances, whose primary origin(backend) is a Varnish instance which processes an ESI-capable app. >> >> So basically: >> >> USA visitor -> Varnish USA -> Varnish primary -> THE APP with ESI blocks >> RUS visitor -> Varnish RUS -> Varnish primary -> THE APP with ESI blocks >> CAN -> Varnish primary -> THE APP with ESI blocks >> >> The APP emits HTML with ESI tags for different blocks, and sure enough, those have different cache policies. >> If a request arrives to an edge Varnish, I want it to talk to the primary Varnish (so as to cache on the edge against a primary cache), but this "Varnish primary" serves the content with ESI already assembled. Thus there is no telling, how long we should cache that full page HTML on the edges. >> >> Q: Is there a magic way to instruct the primary Varnish to not do ESI processing on the content that was already cached ?? >> Meaning keep things as usual if request arrives directly to primary Varnish (ESI on), but receive non-assembled HTML (with esi tags inside) otherwise, so that edges can do assembling themselves, and thus cache things on the edge with proper TTLs for blocks. >> >> Or I just have to resort to completely disabling do_esi on the primary server? Which I could do, but that must mean that the primary Varnish cannot serve visitors directly (= loosing the edge location with lowest latency to nearby users). >> >> _______________________________________________ >> 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: