Giter Site home page Giter Site logo

varnish-elb-systemd's Introduction

Varnish + ELB + systemd

This repository provides a script and several systemd-units to allow for using Varnish in combination with an AWS Elastic Load Balancer, or theoretically any backend that has constantly changing DNS records.

The script itself can be used without systemd as well, but the units here are provided for convenience.

Script overview

The script is supposed to run periodically. It takes the target hostname and a name to use for the Varnish director as its arguments. The director name is also used for the VCL file name at /etc/varnish/${DIRECTOR}.vcl.

When run it will resolve the provided hostname and create a director with an entry for every A record that the hostname eventually resolves to.

The configuration is written to a temporary file and only replaced at the specified path if the records have changed.

Units overview

There are two pairs of related units included. To make this setup work two things need to be done:

  • regenerating the Varnish configuration periodically
  • reloading Varnish if the configuration changes

The two unit pairs tackle these tasks separately.

varnish-elb.{timer|service} provide a pair that will periodically run the script. This is configured to run every 30 seconds, half the TTL of an ELB A record.

varnish-elb[@].{path|service} provides a path unit that watches the specified VCL file (presumed to be in /etc/varnish) and triggers the reload unit if the VCL changes.

Configuration

A simple environment file in /etc/defaults/varnish:

TARGET_HOSTNAME=some-elb-instance.elb.amazonaws.com
DIRECTOR=elb

Usage example

  • Place the script in /usr/local/bin
  • Place the units in /usr/lib/systemd/system
  • Place a configuration file in /etc/defaults/varnish-elb
  • Start the timer unit (systemctl start varnish-elb.timer)
  • Start the path unit (assuming director is elb: systemctl start [email protected]

varnish-elb-systemd's People

Contributors

tazjin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.