Skip to content

[RFC] server.vcls for per-domain VCLs #97

@gquintard

Description

@gquintard

The current helm charts don't allow for split configuration per domain (https://info.varnish-software.com/blog/one-vcl-per-domain), but it's quite easy to make happen, we just need to agree on an API.

In short, I want to introduce a new field, server.vcls , looking like this:

vcls:
  # routes lists all the "main" VCLs, one for each domains or subpath to cover
  routes:
    # by default, the name is use for the VCL name, label, and the hostname the VCL will be used for.
    # files will be placed in /etc/varnish/routes
    foo.com:
      content: |
        vcl 4.1;
        backend default none;
        sub vcl_recv { return (synth(200)); };

    # some VCL may be used on multiple domain/subpaths
    some_alias:
      # matcher's type isn't defined yet, I'm sure @Alve will have opinions :-)
      # for now we can use a list of wildcard
      matcher:
        - example.com/admin/*
        - *.api.bar.com
      # instead of content, you migth just want to point at a file on disk
      path: /etc/some/file.vcl

    # we can make "default" special, in that it will be run in case no other route matches
    default:
      content: |
        vcl 4.1
        backend default none;
        sub vcl_recv { return (synth(404)); };

  # finally we list all the non-main VCLs, i.e. the files included directly or recursively by the VCLs in vcls.routes
  # files will be placed in /etc/varnish/includes
  includes:
    an_include.vcl: |
      ...
    another_include.vcl: |
      ...

This would allow to supersede server.vclConfigs, replacing

server:
  vclConfigs:
    default.vcl: |
      vcl 4.1;
      include "included.vcl";
    included.vcl: |
      backend default none;

with

server:
  routes:
    default:
      content: |
        vcl 4.1;
        include "included.vcl";
  includes:
    included.vcl: |
      backend default none;

it's slightly longer, but this would be a unified syntax that would cover the regular case and per-domain configuration

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions