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.
Set it up
- 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). - Each server's private address.
lf setupfinds it for a new server and remembers it. Set it by hand where setup found none or the wrong one. - The servers trust the edge.
lf traefik behindmakes their Traefik accept plain HTTP from the edge. - The site serves plain HTTP behind the edge. Mark its main service
tls: lband deploy. - 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 blogHow 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 addrefuses a server without a private address, a server that does not trust the edge, and a service withouttls: lb.- The edge sends plain HTTP. If a server's
--private-ipis a public address,lf edge addneeds--publicand a yes in a terminal. lf edge addwarns for each domain that does not point at the edge yet. The edge gets the certificates.- In the project folder,
.landfall.jsonkeeps the edge asedge. - The edge checks each server with the main service's
healthcheck, every 5s unless it sets aninterval. A server that fails it gets no requests. Without one, landfall warns. - Traefik keeps no time of the last check.
lf edgeshows 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 addagain 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. Removex-landfall.tls: lb, deploy, then point DNS at the servers. lf undoreverts each change.- The edge's access log names the server that answered each request.
lf traffic -s <edge> --jsonlists them per host asupstreams. 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: 30After the switch, the server goes back in, with the domains and health check of the new release.
- 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 edge1reverts them. - Without the edge in
.landfall.json, or without its file on the edge, every server switches while it gets requests.