NullifyNetwork

The blog and home page of Simon Soanes
Skip to content
[ Log On ]

Edge Load Balancer

Charon is a new Traefik edge load balancer based on an Alpine Linux VM deployment.

Beyond the usual download of Traefik it consists of a startup script:-

/etc/init.d/traefik

#!/sbin/openrc-run
name="traefik"
command="/home/traefik/traefik"
command_args=""
command_user="traefik"
command_background=true
pidfile="/etc/traefik/traefik.pid" 

depend() {
<------>need net localmount
<------>after firewall
}

A static configuration:-

/etc/traefik/Traefik.yml

## Static configuration
entryPoints:
  web:
      address: ":80"
  web-secure:
      address: ":443"

providers:
  file:
      filename: /home/traefik/dynamic_conf.yml
      watch: true

(Cert configuration removed for security reasons)

And a dynamic configuration:-

/home/traefik/dynamic_conf.yml

#This is the config file for the edge router, it takes effect a brief moment after being saved
http:
  routers:
    dashboard:
      rule: "PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
      service: api@internal
      middlewares:
        - user-auth
      entryPoints:
        - internal

    test-site:
      rule: "Host(`test-site.nullify.net`)"
      # && Path(`/foo-path/`)
      service: testserver
      middlewares:
        - httpsredirect

    test-site-secure:
      rule: "Host(`test-site.nullify.net`)"
      service: testserver
      tls: 
        certResolver: basic

  services:
    testserver:
      loadBalancer:
        servers:
        - url: http://testsite-host.vm.nullify.net/

  middlewares:
    # Define an authentication mechanism
    user-auth:
      basicAuth:
        users:
        - test:htpassword/

    httpsredirect:
      redirectScheme:
        scheme: https
        # permanent: true