Skip to content
landfall

An edge in front

An edge is one more landfall server in front of the group. Its Traefik holds the site's domains, gets their certificates and sends each request to a server of the group. DNS points at the edge only. When a server fails its health check, the edge stops sending it requests, so the site stays up.

diagramdiagram

Set it up

  1. A private network. The edge reaches the servers over one. Use your provider's private network, or make one with lf network add (see A private network).
  2. Each server's private address. lf setup finds it for a new server and remembers it. Set it by hand where setup found none or the wrong one.
  3. The servers trust the edge. lf traefik behind makes their Traefik accept plain HTTP from the edge.
  4. The site serves plain HTTP behind the edge. Mark its main service tls: lb and deploy.
  5. Put the edge in front. lf edge add, then point the domains' DNS at the edge.
# 2. each server's address in the private network (lf network add sets them itself)
lf server config edge1 --private-ip 10.77.0.1
lf server config vps1 --private-ip 10.77.0.2
lf server config vps2 --private-ip 10.77.0.3
# 3. the servers of the group trust the edge
lf traefik behind 10.77.0.1 -s vps1
lf traefik behind 10.77.0.1 -s vps2
# 4. compose.yaml: the main service, then lf deploy
services:
  web:
    x-landfall:
      tls: lb
      healthcheck: { path: /up }
# 5. put edge1 in front of blog's group
lf edge add edge1 blog

How setup finds the private address:

  • It takes the default route's address when that is private, like on a LAN.
  • Otherwise it takes a private address on another interface. That is where Hetzner and DigitalOcean put their private networks.
  • It does not change the address of a server landfall knows already.

How it works

  • The edge sends plain HTTP to port 80 of each server's private address. The servers answer it there only to the edge: any other address gets 403.
  • lf edge add refuses a server without a private address, a server that does not trust the edge, and a service without tls: lb.
  • The edge sends plain HTTP. If a server's --private-ip is a public address, lf edge add needs --public and a yes in a terminal.
  • lf edge add warns for each domain that does not point at the edge yet. The edge gets the certificates.
  • In the project folder, .landfall.json keeps the edge as edge.
  • The edge checks each server with the main service's healthcheck, every 5s unless it sets an interval. A server that fails it gets no requests. Without one, landfall warns.
  • Traefik keeps no time of the last check. lf edge shows whether each server is up now and how often it is checked.
  • A sticky service stays sticky: the edge sets its own cookie, <name>-edge.
  • Run lf edge add again after a change of domains or health check, or to add a server. Weights and servers you turned off stay.
  • The edge's file is /opt/landfall/traefik/dynamic/edge-<site>.yml. Its first line holds the state as JSON.
# each server's weight, state and health
lf edge blog
# the same, with what each server answered in the last hour: requests, 4xx, 5xx
lf edge blog --stats --since 1h
# take vps2 out, send twice the requests to vps1
lf edge blog vps2=off vps1=2
# put vps2 back
lf edge blog vps2=on
# take the edge away
lf edge rm blog
  • A weight is a number: a server with 2 gets twice the requests of one with 1 (the default).
  • Turning off the last server that is on needs --force. The site would answer 503.
  • After lf edge rm, the servers still serve the site to the edge only. Remove x-landfall.tls: lb, deploy, then point DNS at the servers.
  • lf undo reverts each change.
  • The edge's access log names the server that answered each request. lf traffic -s <edge> --json lists them per host as upstreams. The web UI's Edge card shows each server's requests per minute, averaged over the Traffic range, and its 4xx and 5xx.

Deploys behind an edge

A group deploy takes each server out of the edge before it switches. It waits for the server's open requests, then switches it. The wait is 5 seconds. drain on the main service sets it, from 0 to 300 seconds:

x-landfall:
  port: 3000
  tls: lb
  drain: 30

After the switch, the server goes back in, with the domains and health check of the new release.

diagramdiagram
  • A server stays in when it is the only one the edge sends requests to.
  • If the deploy fails, the edge goes back to what it was, like the servers.
  • The edge's changes are part of the deploy's run: lf undo <run id> -s edge1 reverts them.
  • Without the edge in .landfall.json, or without its file on the edge, every server switches while it gets requests.