On Mon, Aug 24, 2020 at 5:43 PM Batanun B <bata...@hotmail.com> wrote: > > Hi, > > I'm experimenting with user defined variables, and when using them in regular > string concatenation, and in synch output, it works fine. But I would like to > use them in the backend definitions, and I simply can't get it to work. > > backend myBackend { > .host = var.get("myBackendHost"); > } > > But that fails with a VCC-compiler error on that line, saying "Expected CSTR > got 'var.get'". > I also tried with the "variable" vmod, but it resulted in the same type of > error. > > Is there any way to get this to work? I would really like to have all > environment specific configuration (including backend hostnames) in an > environment specific vcl file, and then include it in the main vcl where the > backend definitions should be (and use the variables). And I would like to > achive this using just VCL (and vmods), so no custom script that does search > and replace or anything like that. > > So, I would like something like this to work: > > default.vcl: > ... > import var; > > include "environment.vcl"; > > backend myBackend { > .host = var.get("myBackendHost"); > } > ... > > environment.vcl: > sub vcl_init { > var.set("myBackendHost", "myHostName"); > }
Hi, You can't do that, but you can move the backend definition inside environment.vcl instead to keep your default.vcl the same across all environments. Dridi _______________________________________________ varnish-misc mailing list varnish-misc@varnish-cache.org https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc