GithubHelp home page GithubHelp logo

isen0011 / traefik-maintenance-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from programic/traefik-maintenance-plugin

0.0 0.0 0.0 80 KB

Traefik maintenance plugin to show visitors a maintenance page.

Go 91.38% HTML 8.62%

traefik-maintenance-plugin's Introduction

Traefik Maintenance Plugin by Programic

Traefik maintenance plugin to show visitors a maintenance page. Useful when upgrading a production environment.

Hosts (by regex) that are under maintenance are retrieved using an http request to an inform url. Permitted ips are retained (such as development team) and other visitors receive a maintenance page with status code 503 Service Unavailable.

This plugin returns the correct response based on the Content-Type header. Currently supported: application/json, text/plain and text/html.

Configuration

The test directory shows a fully working setup for using this plugin in combination with Traefik in Docker. You can use this configuration for your own project. Below an explanation.

The following declaration (given here in YAML) defines a plugin:

# Static configuration

experimental:
  maintenance:
    moduleName: github.com/programic/traefik-maintenance-plugin
    version: "v0.0.1" # Grep the latest version 

Here is an example of a file provider dynamic configuration (given here in YAML), where the interesting part is the http.middlewares section:

# Dynamic configuration

http:
  middlewares:
    maintenance: # Middleware name
      plugin:
        maintenance: # Plugin name
          informUrl: "http://inform/inform.json"
          informInterval: 60
          informTimeout: 5

Properties

  • informUrl (required): Url to the inform.json to check if hosts are under maintenance. In directory test/services/inform/inform.json is an example.
  • informInterval (optional): Every how many seconds should the inform url be consulted.
  • informTimeout (optional): The timeout of the inform url.

Local development

To test this plugin for local development, you can do the following.

Prerequisites

  • docker and docker-compose installed.
  • *.test refers to your local development environment through dnsmasq.

1. Start the local development environment

$ cd test
$ docker-compose up -d

2. Open your browser

  1. Go to maintenance.test.
  2. You will now see a maintenance page or a welcome page.
  3. Change the ip in file test/services/inform/inform.json to your Docker network ip.
  4. Go back to the maintenance.test and see what happened.
  5. Check what a json or png response looks like.

3. Happy coding!

You can now edit the plugin locally. Don't forget to restart Docker every time:

$ docker-compose down && docker-compose up -d

traefik-maintenance-plugin's People

Contributors

remcowolvenne avatar isen0011 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.