<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sanjay Singh</title>
    <description>The latest articles on DEV Community by Sanjay Singh (@sanjay_singh_1).</description>
    <link>https://dev.to/sanjay_singh_1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3961409%2F9efd98f2-cabb-46b0-817f-1f8cefd2c79b.jpg</url>
      <title>DEV Community: Sanjay Singh</title>
      <link>https://dev.to/sanjay_singh_1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sanjay_singh_1"/>
    <language>en</language>
    <item>
      <title>WireGuard VPN Setup: A Private Network Between Your Servers</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Sun, 06 Dec 2026 05:41:38 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/wireguard-vpn-setup-a-private-network-between-your-servers-5edo</link>
      <guid>https://dev.to/sanjay_singh_1/wireguard-vpn-setup-a-private-network-between-your-servers-5edo</guid>
      <description>&lt;p&gt;Sooner or later you want a private network between your machines: a laptop that can reach a database without exposing it to the internet, servers that talk to each other over an encrypted link, or an SSH port that only you can see. A VPN does this, and &lt;strong&gt;WireGuard&lt;/strong&gt; makes it unusually simple. It is built into the Linux kernel, uses modern cryptography, and a working setup is often under twenty lines of configuration per machine.&lt;/p&gt;

&lt;p&gt;This guide builds a small VPN step by step, explains the one concept that confuses everyone (&lt;code&gt;AllowedIPs&lt;/code&gt;), and shows how to use the tunnel to lock down SSH. It builds on the SSH, networking, and server hardening posts in this series.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; Golden rule: give every device its own key pair, and treat &lt;code&gt;AllowedIPs&lt;/code&gt; as both a routing table and a firewall for what each peer may send.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Design We Will Build
&lt;/h2&gt;

&lt;p&gt;We will use a &lt;strong&gt;hub-and-spoke&lt;/strong&gt; layout. One server with a public IP address (the hub) listens for connections. Everything else connects to it, so laptops and servers behind home routers or NAT work without opening any ports on their side.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNptj0FrwkAQhf_KdM6b1FgLEkSwLRIhhaDYS9bDJpmYpZvssrvRWvG_F81BDz2-x_femzljqSvCGGulj2UjrId0zTsAgDTnmArjtZkV9nkejcJpOArHHHcwC4I5JDnHpC_AkT2QfWSimzB9oWQJq4zB9iOD12g6HnHcDeWLnOPCmH_CL_eBAc1yjlmjO3qkJncKGbZkWyErjM_oG2qv_1RUi155ZIPzJawUhSJ3ZWrd-aVopTphjIEwRlHgTs5Ty-BNye77U5Sbm17qzjPguKG9JtiuODJY60J7zSAhdSAvS8FgYaVQDJzoXODIyhrZbWQjf6-3RBPzg5cLw2L_rpW2GOPTsZGe8PIHgLJ2Iw%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNptj0FrwkAQhf_KdM6b1FgLEkSwLRIhhaDYS9bDJpmYpZvssrvRWvG_F81BDz2-x_femzljqSvCGGulj2UjrId0zTsAgDTnmArjtZkV9nkejcJpOArHHHcwC4I5JDnHpC_AkT2QfWSimzB9oWQJq4zB9iOD12g6HnHcDeWLnOPCmH_CL_eBAc1yjlmjO3qkJncKGbZkWyErjM_oG2qv_1RUi155ZIPzJawUhSJ3ZWrd-aVopTphjIEwRlHgTs5Ty-BNye77U5Sbm17qzjPguKG9JtiuODJY60J7zSAhdSAvS8FgYaVQDJzoXODIyhrZbWQjf6-3RBPzg5cLw2L_rpW2GOPTsZGe8PIHgLJ2Iw%3Ftype%3Dpng" alt="Mermaid Diagram" width="360" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every device gets an address in a private VPN subnet, here &lt;code&gt;10.8.0.0/24&lt;/code&gt;. Pick a range that does &lt;strong&gt;not&lt;/strong&gt; overlap with the networks you use at home or in the office. The very common &lt;code&gt;192.168.0.0/24&lt;/code&gt; and &lt;code&gt;192.168.1.0/24&lt;/code&gt; cause routing conflicts as soon as you connect from a home network that uses them.&lt;/p&gt;

&lt;h2&gt;
  
  
  How WireGuard Thinks
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Each machine has a &lt;strong&gt;private key&lt;/strong&gt; (secret, never shared) and a &lt;strong&gt;public key&lt;/strong&gt; (given to the other side).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A VPN interface, usually &lt;code&gt;wg0&lt;/code&gt;, has an address and a list of &lt;strong&gt;peers&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A peer is identified by its public key. There are no usernames, passwords, or certificates to manage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It runs over &lt;strong&gt;UDP&lt;/strong&gt; on a port you choose (51820 by convention).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is quiet: it sends nothing when idle, and replies to no one who does not hold a known key.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AllowedIPs, explained once
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;AllowedIPs&lt;/code&gt; on a peer does two jobs at the same time:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Outgoing:&lt;/strong&gt; traffic to these addresses is sent through that peer (it works as a route).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Incoming:&lt;/strong&gt; packets from that peer are accepted only if their source address is in this list (it works as a filter).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Where&lt;/th&gt;
&lt;th&gt;Peer entry&lt;/th&gt;
&lt;th&gt;AllowedIPs&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;On the hub&lt;/td&gt;
&lt;td&gt;the laptop&lt;/td&gt;
&lt;td&gt;10.8.0.2/32&lt;/td&gt;
&lt;td&gt;Only the laptop's VPN address may come from this peer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;On the laptop&lt;/td&gt;
&lt;td&gt;the hub&lt;/td&gt;
&lt;td&gt;10.8.0.0/24&lt;/td&gt;
&lt;td&gt;Send VPN-subnet traffic to the hub&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;On the laptop&lt;/td&gt;
&lt;td&gt;the hub (full tunnel)&lt;/td&gt;
&lt;td&gt;0.0.0.0/0, ::/0&lt;/td&gt;
&lt;td&gt;Send all internet traffic through the hub&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; A mistake in &lt;code&gt;AllowedIPs&lt;/code&gt; is the cause of most "the tunnel is up but nothing works" problems. When in doubt, check this first.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  1. Install WireGuard
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install wireguard           &lt;span class="c"&gt;# Debian / Ubuntu&lt;/span&gt;
sudo dnf install wireguard-tools     &lt;span class="c"&gt;# Fedora / RHEL-family (the kernel module is built in on modern kernels)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the UDP port on the hub's firewall, and in any cloud security group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ufw allow 51820/udp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Generate Keys
&lt;/h2&gt;

&lt;p&gt;Run this on &lt;strong&gt;each&lt;/strong&gt; machine, and keep the private key on that machine only:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;umask&lt;/span&gt; 077
wg genkey &lt;span class="o"&gt;|&lt;/span&gt; tee private.key &lt;span class="o"&gt;|&lt;/span&gt; wg pubkey &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; public.key
cat public.key                      &lt;span class="c"&gt;# this one is safe to share&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;umask 077&lt;/code&gt; makes the files readable only by you. You will paste each machine's private key into its own config file, and its public key into the other side's config.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Configure the Hub
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;/etc/wireguard/wg0.conf&lt;/code&gt; on the hub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[Interface]&lt;/span&gt;
&lt;span class="na"&gt;Address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;10.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;
&lt;span class="na"&gt;ListenPort&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;51820&lt;/span&gt;
&lt;span class="na"&gt;PrivateKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;HUB_PRIVATE_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="k"&gt;[Peer]&lt;/span&gt;
&lt;span class="c1"&gt;# laptop
&lt;/span&gt;&lt;span class="na"&gt;PublicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;LAPTOP_PUBLIC_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;AllowedIPs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;10.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;

&lt;span class="k"&gt;[Peer]&lt;/span&gt;
&lt;span class="c1"&gt;# app server
&lt;/span&gt;&lt;span class="na"&gt;PublicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;APPSERVER_PUBLIC_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;AllowedIPs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;10.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lock the file down, because it holds a private key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo chmod 600 /etc/wireguard/wg0.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If peers should be able to reach &lt;strong&gt;each other&lt;/strong&gt; through the hub (laptop to app server, for example), enable IP forwarding and allow forwarded traffic on the tunnel interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'net.ipv4.ip_forward=1'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sudo tee /etc/sysctl.d/99-wireguard.conf
sudo sysctl --system
sudo ufw route allow &lt;span class="k"&gt;in&lt;/span&gt; on wg0 out on wg0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Configure a Client
&lt;/h2&gt;

&lt;p&gt;On the laptop, create &lt;code&gt;/etc/wireguard/wg0.conf&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[Interface]&lt;/span&gt;
&lt;span class="na"&gt;Address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;10.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;
&lt;span class="na"&gt;PrivateKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;LAPTOP_PRIVATE_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="k"&gt;[Peer]&lt;/span&gt;
&lt;span class="na"&gt;PublicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;HUB_PUBLIC_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="na"&gt;Endpoint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vpn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;51820&lt;/span&gt;
&lt;span class="na"&gt;AllowedIPs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;10.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;
&lt;span class="na"&gt;PersistentKeepalive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Endpoint&lt;/code&gt; is the hub's public address and port. Only the client needs it, because the hub learns the client's address when the client connects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;PersistentKeepalive = 25&lt;/code&gt; sends a small packet every 25 seconds, keeping NAT routers from forgetting the connection. Use it on any peer behind NAT.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The app server's config looks the same, with its own address (&lt;code&gt;10.8.0.3/24&lt;/code&gt;) and private key.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Start It and Check
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo wg-quick up wg0                   &lt;span class="c"&gt;# bring the tunnel up&lt;/span&gt;
sudo wg show                           &lt;span class="c"&gt;# status&lt;/span&gt;
ping -c 3 10.8.0.1                     &lt;span class="c"&gt;# from the laptop: can it reach the hub?&lt;/span&gt;
sudo wg-quick down wg0                 &lt;span class="c"&gt;# bring it down&lt;/span&gt;
sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; --now wg-quick@wg0     &lt;span class="c"&gt;# start at boot (run this on every machine)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A healthy &lt;code&gt;wg show&lt;/code&gt; on the hub looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;interface&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;wg0&lt;/span&gt;
  &lt;span class="na"&gt;public key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;hub public key&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;listening port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;51820&lt;/span&gt;

&lt;span class="na"&gt;peer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;laptop public key&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;198.51.100.7:49382&lt;/span&gt;
  &lt;span class="na"&gt;allowed ips&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10.8.0.2/32&lt;/span&gt;
  &lt;span class="na"&gt;latest handshake&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;41 seconds ago&lt;/span&gt;
  &lt;span class="na"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1.20 MiB received, 3.04 MiB sent&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The line to look for is &lt;code&gt;latest handshake&lt;/code&gt;. If a peer shows no handshake at all, the two sides have not successfully talked yet. Remember that WireGuard is silent when idle, so a peer with no recent traffic may show an old handshake, and that is normal. Send a ping to trigger one.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Add More Peers
&lt;/h2&gt;

&lt;p&gt;Adding a device means generating its keys, adding a &lt;code&gt;[Peer]&lt;/code&gt; block on the hub, and giving the device a config. This script, run as root on the hub, automates that. It applies the change without dropping existing connections.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# add-peer.sh NAME VPN_IP   (run as root on the hub, for example: ./add-peer.sh phone 10.8.0.4)&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail
&lt;span class="nb"&gt;umask&lt;/span&gt; 077

&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;${1:?Usage: $0 NAME VPN_IP}&lt;/span&gt;
&lt;span class="nv"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;${2:?Usage: $0 NAME VPN_IP}&lt;/span&gt;
&lt;span class="nv"&gt;endpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"vpn.example.com:51820"&lt;/span&gt;          &lt;span class="c"&gt;# the hub's public address&lt;/span&gt;

&lt;span class="nv"&gt;priv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;wg genkey&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;pub&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s'&lt;/span&gt; &lt;span class="s2"&gt;"$priv"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; wg pubkey&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;server_pub&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;wg show wg0 public-key&lt;span class="o"&gt;)&lt;/span&gt;

cat &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; /etc/wireguard/wg0.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;EOF

&lt;span class="o"&gt;[&lt;/span&gt;Peer&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="c"&gt;# ${name}&lt;/span&gt;
PublicKey &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;${pub}&lt;/span&gt;
AllowedIPs &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;${ip}&lt;/span&gt;/32
EOF

wg syncconf wg0 &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;wg-quick strip wg0&lt;span class="o"&gt;)&lt;/span&gt;     &lt;span class="c"&gt;# apply without restarting the interface&lt;/span&gt;

cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"/root/${name}.conf"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;EOF
&lt;span class="o"&gt;[&lt;/span&gt;Interface&lt;span class="o"&gt;]&lt;/span&gt;
Address &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;${ip}&lt;/span&gt;/24
PrivateKey &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;${priv}&lt;/span&gt;

&lt;span class="o"&gt;[&lt;/span&gt;Peer&lt;span class="o"&gt;]&lt;/span&gt;
PublicKey &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;${server_pub}&lt;/span&gt;
Endpoint &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;${endpoint}&lt;/span&gt;
AllowedIPs &lt;span class="o"&gt;=&lt;/span&gt; 10.8.0.0/24
PersistentKeepalive &lt;span class="o"&gt;=&lt;/span&gt; 25
EOF

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Client config written to /root/${name}.conf. Copy it securely, then delete it."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; The generated client file contains that device's &lt;strong&gt;private key&lt;/strong&gt;. Move it over a secure channel (for example &lt;code&gt;scp&lt;/code&gt;), and delete it from the hub afterward. Anyone who has the file can impersonate that device.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To remove a device, delete its &lt;code&gt;[Peer]&lt;/code&gt; block from &lt;code&gt;wg0.conf&lt;/code&gt; and run the same &lt;code&gt;wg syncconf&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;For a phone, install the WireGuard app and import the config by scanning a QR code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install qrencode
qrencode -t ansiutf8 &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; /root/phone.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. Put the Tunnel to Work
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Keep SSH off the public internet
&lt;/h3&gt;

&lt;p&gt;The most valuable use of a private network is hiding administrative services. Once the VPN works, allow SSH only from inside it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ufw allow &lt;span class="k"&gt;in&lt;/span&gt; on wg0 to any port 22 proto tcp     &lt;span class="c"&gt;# SSH only via the tunnel&lt;/span&gt;
&lt;span class="c"&gt;# Test this FIRST: connect with  ssh user@10.8.0.1  over the VPN, in a second terminal.&lt;/span&gt;
sudo ufw delete allow OpenSSH                         &lt;span class="c"&gt;# then remove the public SSH rule&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; Do not remove the public SSH rule until you have logged in through the tunnel in a &lt;strong&gt;second terminal&lt;/strong&gt; and confirmed that it works. If the tunnel fails after you close the public port, you are locked out and will need your provider's web console.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Reach private services
&lt;/h3&gt;

&lt;p&gt;Bind databases, dashboards, and admin panels to the VPN address instead of the public one, for example &lt;code&gt;listen_addresses = '10.8.0.1'&lt;/code&gt; for PostgreSQL, and connect over &lt;code&gt;10.8.0.1&lt;/code&gt; from your laptop. They never appear on the public internet at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  Optional: send all traffic through the hub
&lt;/h3&gt;

&lt;p&gt;Full-tunnel setup (route all internet traffic through the hub)&lt;/p&gt;

&lt;p&gt;On the hub, enable forwarding (section 3) and add NAT rules to the &lt;code&gt;[Interface]&lt;/code&gt; section of &lt;code&gt;wg0.conf&lt;/code&gt;. Replace &lt;code&gt;eth0&lt;/code&gt; with the hub's public network interface (check with &lt;code&gt;ip -br a&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="na"&gt;PostUp&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;iptables&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="no"&gt;A&lt;/span&gt; &lt;span class="no"&gt;FORWARD&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="no"&gt;ACCEPT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;iptables&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="n"&gt;nat&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="no"&gt;A&lt;/span&gt; &lt;span class="no"&gt;POSTROUTING&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="n"&gt;eth0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="no"&gt;MASQUERADE&lt;/span&gt;
&lt;span class="na"&gt;PostDown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;iptables&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="no"&gt;D&lt;/span&gt; &lt;span class="no"&gt;FORWARD&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="no"&gt;ACCEPT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;iptables&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="n"&gt;nat&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="no"&gt;D&lt;/span&gt; &lt;span class="no"&gt;POSTROUTING&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt; &lt;span class="n"&gt;eth0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="no"&gt;MASQUERADE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;On the client, change the peer's &lt;code&gt;AllowedIPs&lt;/code&gt; and set a DNS server:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[Interface]&lt;/span&gt;
&lt;span class="na"&gt;Address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;10.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;
&lt;span class="na"&gt;PrivateKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
&lt;span class="na"&gt;DNS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;

&lt;span class="k"&gt;[Peer]&lt;/span&gt;
&lt;span class="na"&gt;PublicKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
&lt;span class="na"&gt;Endpoint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vpn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;51820&lt;/span&gt;
&lt;span class="na"&gt;AllowedIPs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;::/&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="na"&gt;PersistentKeepalive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;If &lt;code&gt;wg-quick&lt;/code&gt; complains that &lt;code&gt;resolvconf&lt;/code&gt; is missing, install it (&lt;code&gt;sudo apt install resolvconf&lt;/code&gt; or &lt;code&gt;openresolv&lt;/code&gt;). All of the client's traffic then appears to come from the hub's IP address, and the hub's bandwidth becomes your bandwidth.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;No handshake appears.&lt;/strong&gt; The UDP packets are not arriving. Check the hub's firewall and cloud security group for UDP 51820, and verify the client's &lt;code&gt;Endpoint&lt;/code&gt;. On the hub, watch for traffic with &lt;code&gt;sudo tcpdump -ni any udp port 51820&lt;/code&gt; while the client connects. If nothing arrives, the problem is the network path. If packets arrive but no handshake follows, the keys are wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The keys are wrong.&lt;/strong&gt; The most common mistake is pasting the &lt;em&gt;private&lt;/em&gt; key where the &lt;em&gt;public&lt;/em&gt; key belongs, or swapping the two machines' keys. Each &lt;code&gt;PublicKey&lt;/code&gt; line must hold the &lt;em&gt;other&lt;/em&gt; side's public key, and &lt;code&gt;PrivateKey&lt;/code&gt; is that machine's own secret. Compare with &lt;code&gt;sudo wg show&lt;/code&gt; (its &lt;code&gt;public key&lt;/code&gt; field must match what the other side has).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There is a handshake, but pings fail.&lt;/strong&gt; Look at &lt;code&gt;AllowedIPs&lt;/code&gt; on both sides. For peer-to-peer traffic through the hub, also confirm that &lt;code&gt;net.ipv4.ip_forward&lt;/code&gt; is &lt;code&gt;1&lt;/code&gt; on the hub, and that the firewall's forward rules allow traffic in and out of &lt;code&gt;wg0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It works from some networks but not others.&lt;/strong&gt; The VPN subnet overlaps with the network you are on. Move the VPN to a less common range, such as &lt;code&gt;10.77.0.0/24&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Large transfers stall while small pings work.&lt;/strong&gt; An MTU problem. WireGuard's default is usually 1420. Try &lt;code&gt;MTU = 1380&lt;/code&gt; in the &lt;code&gt;[Interface]&lt;/code&gt; section, and test with &lt;code&gt;ping -M do -s 1300 10.8.0.1&lt;/code&gt;. The networking cheat sheet in this series explains the technique.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS does not work through the tunnel.&lt;/strong&gt; For a full tunnel, set &lt;code&gt;DNS =&lt;/code&gt; in the client's &lt;code&gt;[Interface]&lt;/code&gt;, and install &lt;code&gt;resolvconf&lt;/code&gt; or &lt;code&gt;openresolv&lt;/code&gt; if &lt;code&gt;wg-quick&lt;/code&gt; needs it. Confirm with &lt;code&gt;resolvectl status&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Warning: /etc/wireguard/wg0.conf is world accessible&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; Run &lt;code&gt;sudo chmod 600 /etc/wireguard/wg0.conf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RTNETLINK answers: File exists&lt;/code&gt; &lt;strong&gt;or&lt;/strong&gt; &lt;code&gt;wg0 already exists&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; The interface is already up. Run &lt;code&gt;sudo wg-quick down wg0&lt;/code&gt; first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The tunnel dies after a while behind NAT.&lt;/strong&gt; Add &lt;code&gt;PersistentKeepalive = 25&lt;/code&gt; on the peer that sits behind NAT.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The hub's address changes.&lt;/strong&gt; If the hub has a dynamic IP, use a DNS name in &lt;code&gt;Endpoint&lt;/code&gt;. Note that WireGuard resolves it when the interface starts, so a changed address needs a restart of the tunnel on the clients.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security Habits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] One key pair per device, never shared and never copied between machines&lt;/li&gt;
&lt;li&gt;[ ] Private keys and config files at mode &lt;code&gt;600&lt;/code&gt;, and never committed to Git&lt;/li&gt;
&lt;li&gt;[ ] The narrowest &lt;code&gt;AllowedIPs&lt;/code&gt; that does the job (use &lt;code&gt;/32&lt;/code&gt; for single hosts)&lt;/li&gt;
&lt;li&gt;[ ] Revoke a lost device immediately by deleting its &lt;code&gt;[Peer]&lt;/code&gt; block&lt;/li&gt;
&lt;li&gt;[ ] Firewall rules that allow administrative services only on &lt;code&gt;wg0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[ ] Access to the hub's own SSH secured, with a console fallback kept in mind&lt;/li&gt;
&lt;li&gt;[ ] A written record of which address and key belong to which device&lt;/li&gt;
&lt;li&gt;[ ] Keys rotated when staff or devices change&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick Reference
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;KEYS       &lt;span class="nb"&gt;umask&lt;/span&gt; 077&lt;span class="o"&gt;;&lt;/span&gt; wg genkey &lt;span class="o"&gt;|&lt;/span&gt; tee private.key &lt;span class="o"&gt;|&lt;/span&gt; wg pubkey &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; public.key
CONFIG     /etc/wireguard/wg0.conf &lt;span class="o"&gt;(&lt;/span&gt;chmod 600&lt;span class="o"&gt;)&lt;/span&gt;   &lt;span class="o"&gt;[&lt;/span&gt;Interface&lt;span class="o"&gt;]&lt;/span&gt; Address, ListenPort, PrivateKey
           &lt;span class="o"&gt;[&lt;/span&gt;Peer&lt;span class="o"&gt;]&lt;/span&gt; PublicKey, AllowedIPs, Endpoint &lt;span class="o"&gt;(&lt;/span&gt;client side&lt;span class="o"&gt;)&lt;/span&gt;, PersistentKeepalive &lt;span class="o"&gt;=&lt;/span&gt; 25
CONTROL    wg-quick up&lt;span class="o"&gt;|&lt;/span&gt;down wg0     systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; --now wg-quick@wg0     wg show
APPLY      wg syncconf wg0 &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;wg-quick strip wg0&lt;span class="o"&gt;)&lt;/span&gt;    &lt;span class="o"&gt;(&lt;/span&gt;no downtime&lt;span class="o"&gt;)&lt;/span&gt;
FIREWALL   ufw allow 51820/udp     net.ipv4.ip_forward=1     ufw route allow &lt;span class="k"&gt;in&lt;/span&gt; on wg0 out on wg0
DEBUG      wg show &lt;span class="o"&gt;(&lt;/span&gt;latest handshake&lt;span class="o"&gt;)&lt;/span&gt;    tcpdump -ni any udp port 51820    check AllowedIPs, MTU, overlapping subnets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;WireGuard's appeal is how little there is to it: a key pair per machine and a short list of peers. The trade-off is that it deliberately leaves out things like user accounts, access policies beyond &lt;code&gt;AllowedIPs&lt;/code&gt;, and automatic discovery of devices. For a handful of servers and a few laptops, that simplicity is a strength. If you later need device management, per-user rules, and NAT traversal for a larger team, tools built on top of WireGuard, such as Tailscale or Headscale, add those layers while keeping the same underlying protocol.&lt;/p&gt;

&lt;p&gt;Try it this week with two machines: a hub with a public IP and any laptop. Get a successful handshake, ping across the tunnel, then restrict SSH to it. Once you have a private network that only your own devices can reach, you will want to move more of your administrative surface behind it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/wireguard-vpn-setup-a-private-network-between-your-servers-oosgd?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>networking</category>
      <category>security</category>
      <category>vpn</category>
    </item>
    <item>
      <title>Why Typed Languages Win in the Agent Era</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Wed, 02 Dec 2026 10:14:49 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/why-typed-languages-win-in-the-agent-era-2nlb</link>
      <guid>https://dev.to/sanjay_singh_1/why-typed-languages-win-in-the-agent-era-2nlb</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; Typed languages are winning on adoption, and agents are plausibly part of the reason. They are not winning on agent performance: in public benchmarks, typed and dynamic languages solve about the same share of tasks. What types do win is cheap, mechanical checking of code nobody on your team wrote.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is a narrower answer than the title promises, so here is the evidence for each half.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where typed languages are winning
&lt;/h2&gt;

&lt;p&gt;In March, &lt;strong&gt;17% of pull requests on GitHub started with an agent's first draft&lt;/strong&gt;. By September it was &lt;strong&gt;more than 40%&lt;/strong&gt;, or 110 million pull requests in a single month. In the same Octoverse 2026 report, TypeScript is first by contributors, ahead of Python and JavaScript, and &lt;strong&gt;Rust grew fastest at 162%&lt;/strong&gt;, with TypeScript at 134% and Python at 118%.&lt;/p&gt;

&lt;p&gt;AI also shows up most in those languages: &lt;strong&gt;TypeScript (44.1%), Python (41.1%) and Rust (40.4%)&lt;/strong&gt; lead the share of merged pull requests with detected AI involvement, while Java is lowest at 21.2%. Among repositories created in 2026, &lt;strong&gt;TypeScript was the main language in 35% of those with an agent signal and 24% of those without&lt;/strong&gt;. GitHub reads this as agent users leaning toward languages whose output is easier to verify. It is a suggestion, and GitHub says its agent signal is a floor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why types should help
&lt;/h2&gt;

&lt;p&gt;The mechanism is easy to see. Say an agent changes a lookup function so it can return &lt;code&gt;undefined&lt;/code&gt; instead of throwing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// The agent changes this from `User` (throws if missing) to `User | undefined`&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sendReceipt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Sending receipt to ${user.email}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;strict&lt;/code&gt; on, the build fails with &lt;code&gt;'user' is possibly 'undefined'&lt;/code&gt;, and it flags every other caller that relied on the old behavior. Rust goes further: in safe code, ownership and borrowing rules rule out use-after-free bugs and data races at compile time.&lt;/p&gt;

&lt;p&gt;Research agrees about where the errors land. In a 2025 study of open-weight models writing TypeScript, &lt;strong&gt;94% of compile errors were type-check failures&lt;/strong&gt;, a figure GitHub's own explainer on typed languages quotes. The same paper found that constraining generation with the type checker cut compile errors by more than half.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the data does not show
&lt;/h2&gt;

&lt;p&gt;That 94% tells you which errors break a typed build. It does not tell you whether agents finish more work. Evil Martians, a Rails consultancy, tested that directly in a November 24, 2026 analysis of public benchmarks, and found no measurable gain from types.&lt;/p&gt;

&lt;p&gt;On SWE-bench Multilingual, with 13 models and the same agent, &lt;strong&gt;typed and dynamic languages both solved about 65% of tasks at the same difficulty&lt;/strong&gt;. The spread inside the typed group (Rust 72%, Go 53%) was bigger than the gap between the groups. &lt;strong&gt;TypeScript did not beat plain JavaScript in any of three benchmarks&lt;/strong&gt; once tasks were labeled by the files each fix edited.&lt;/p&gt;

&lt;p&gt;Agents also barely used the checker. They ran &lt;code&gt;tsc&lt;/code&gt; in 1 of 10 TypeScript runs. In Ruby runs on one Rails app, adding Sorbet or RBS left the solve rate at 57% to 61%, against 58% for plain Ruby, while the type tools took 20% to 28% of agent time. Told to type-check, agents did, then often quieted the checker with casts or &lt;code&gt;untyped&lt;/code&gt; signatures, and the checker caught no bug the tests had missed.&lt;/p&gt;

&lt;p&gt;Treat this as strong but not final. The benchmark agents had only a bash shell and no language server, the Ruby runs were small, and the authors sell benchmarking, though they publish their data and scripts. The analysis also measures whether agents pass hidden tests, not how much human review effort types save.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what do typed languages win?
&lt;/h2&gt;

&lt;p&gt;Two things. They win adoption, because TypeScript and Rust are growing fastest and agents show up most in them. And they win cheap checking: a compiler tells you in seconds whether a change fits the rest of the code, whoever wrote it.&lt;/p&gt;

&lt;p&gt;What they have not shown is that agents finish more tasks. In the Ruby and Rust runs, verifying work took 30% to 55% of agent time and reading project code 14% to 44%, while fixing type or compiler errors took under 4%.&lt;/p&gt;

&lt;p&gt;If you already use TypeScript, nothing here says to leave. If you use Python or JavaScript, nothing here says to migrate for the agents' sake. Either way, keep a fast test suite as the gate, and if you use types, turn on &lt;code&gt;strict&lt;/code&gt; and block &lt;code&gt;any&lt;/code&gt;, &lt;code&gt;@ts-ignore&lt;/code&gt; and type assertions so an agent cannot silence the checker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sources:&lt;/strong&gt; GitHub, &lt;a href="https://github.blog/news-insights/octoverse/octoverse-commits-pushes-reach-new-highs-in-2026-as-developers-build-with-agents/" rel="noopener noreferrer"&gt;Octoverse 2026&lt;/a&gt; and &lt;a href="https://github.blog/ai-and-ml/llms/why-ai-is-pushing-developers-toward-typed-languages" rel="noopener noreferrer"&gt;Why AI is pushing developers toward typed languages&lt;/a&gt;; Evil Martians, &lt;a href="https://evilmartians.com/chronicles/type-errors-cost-our-coding-agents-under-one-percent-of-their-time" rel="noopener noreferrer"&gt;Type errors cost our coding agents under 1% of their time&lt;/a&gt; (November 24, 2026); Mündler et al., &lt;a href="https://arxiv.org/abs/2504.09246" rel="noopener noreferrer"&gt;Type-Constrained Code Generation with Language Models&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/why-typed-languages-win-in-the-agent-era-e1m1u?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aiagents</category>
      <category>githuboctoverse</category>
      <category>python</category>
      <category>rust</category>
    </item>
    <item>
      <title>Gmail is ending "Send as" in January 2027: what it means for Cloudflare Email Routing</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Tue, 01 Dec 2026 06:37:20 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/gmail-is-ending-send-as-in-january-2027-what-it-means-for-cloudflare-email-routing-e3o</link>
      <guid>https://dev.to/sanjay_singh_1/gmail-is-ending-send-as-in-january-2027-what-it-means-for-cloudflare-email-routing-e3o</guid>
      <description>&lt;p&gt;&lt;strong&gt;The short version:&lt;/strong&gt; From January 2027, Gmail stops letting you send as addresses it doesn't host. If you forward &lt;code&gt;you@yourdomain.com&lt;/code&gt; into Gmail with Cloudflare Email Routing, forwarding keeps working, but your replies can no longer go out as that address from Gmail. You need another way to send.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changes
&lt;/h2&gt;

&lt;p&gt;Google is removing three features for non-Google accounts: &lt;strong&gt;"Send as"&lt;/strong&gt;, &lt;strong&gt;Gmailify&lt;/strong&gt;, and &lt;strong&gt;POP fetching&lt;/strong&gt; ("Check mail from other accounts"). Google also says it may restrict new Send as setups before the cutoff.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Still works:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Forwarding other providers' mail into Gmail&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IMAP and POP access to Gmail from Apple Mail, Outlook, Thunderbird and similar apps&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send as for Google-hosted addresses (other Gmail addresses, Google Workspace aliases)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mail you have already imported&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Cloudflare users are affected:&lt;/strong&gt; Email Routing only forwards mail. It doesn't host a mailbox, so your domain address counts as a third-party address to Gmail, even if your Send as entry goes out through &lt;code&gt;smtp.gmail.com&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four ways to keep replying from your domain
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Keeps Cloudflare Routing&lt;/th&gt;
&lt;th&gt;Reply as your domain&lt;/th&gt;
&lt;th&gt;Yearly cost (US list, one person)&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A. Read in Gmail, send from a desktop app through Cloudflare SMTP&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Desktop app only&lt;/td&gt;
&lt;td&gt;$60 (Workers Paid)&lt;/td&gt;
&lt;td&gt;One or two domains&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B. Move the domain to a mailbox host&lt;/td&gt;
&lt;td&gt;No, MX moves&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Migadu Micro $19, Fastmail $60&lt;/td&gt;
&lt;td&gt;A few domains, IMAP and a phone app&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C. Google Workspace Business Starter&lt;/td&gt;
&lt;td&gt;No, MX moves&lt;/td&gt;
&lt;td&gt;Yes, inside Gmail&lt;/td&gt;
&lt;td&gt;$84 annual plan ($100.80 flexible)&lt;/td&gt;
&lt;td&gt;Teams that want Docs, Drive and Meet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;D. An inbox in your own Cloudflare account (for example, the Mac app EmailFast)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;$60 plus the app&lt;/td&gt;
&lt;td&gt;Many domains with catch-all&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A few notes on option B:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Migadu Micro allows 200 incoming and 20 outgoing messages a day, shared across the whole account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;iCloud+ supports up to five custom domains, but with a cap on addresses per domain (Apple's own pages list different caps, so check yours).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An MX record can only point one way. Moving to any host means Cloudflare Email Routing stops receiving for that domain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Option A in practice
&lt;/h2&gt;

&lt;p&gt;Cloudflare added authenticated SMTP submission on 8 June 2026, in beta. It's what makes this option possible without writing code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Onboard the domain.&lt;/strong&gt; In the dashboard, go to &lt;strong&gt;Compute &amp;gt; Email Service &amp;gt; Email Sending &amp;gt; Onboard Domain&lt;/strong&gt;. Cloudflare adds its sending records (MX, SPF, DKIM) on the &lt;code&gt;cf-bounce&lt;/code&gt; subdomain, separate from your Email Routing records, so receiving isn't affected. It also adds a DMARC record at &lt;code&gt;_dmarc.yourdomain.com&lt;/code&gt; if you don't already have one (see trap 1).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Create an API token&lt;/strong&gt; with the &lt;strong&gt;Email Sending: Edit&lt;/strong&gt; permission. Treat it like a password: anyone holding it can send as any domain you've onboarded on that account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Add the server to your mail app:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="s"&gt;smtp.mx.cloudflare.net&lt;/span&gt;
&lt;span class="na"&gt;Port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="mi"&gt;465&lt;/span&gt;
&lt;span class="na"&gt;Security&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;SSL/TLS (implicit TLS)&lt;/span&gt;
&lt;span class="na"&gt;Auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="s"&gt;Password&lt;/span&gt;
&lt;span class="na"&gt;Username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;api_token        (the literal text)&lt;/span&gt;
&lt;span class="na"&gt;Password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;&amp;lt;your API token&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Port 587 with STARTTLS and port 25 are not supported for sending. If your app says the server is unavailable, check the TLS setting first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Apple Mail catch:&lt;/strong&gt; Mail sends everything from an account through that account's single outgoing server. If that account is your Gmail, mail from your &lt;code&gt;@gmail.com&lt;/code&gt; address also goes to Cloudflare, which refuses it because &lt;code&gt;gmail.com&lt;/code&gt; isn't an onboarded domain. Either send only domain mail from that account, or use Thunderbird on desktop, which lets each identity have its own outgoing server (Thunderbird for Android doesn't).&lt;/p&gt;

&lt;h2&gt;
  
  
  Three traps before you touch DNS
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. The DMARC record.&lt;/strong&gt; If your domain has no DMARC record, onboarding adds one with &lt;code&gt;p=reject&lt;/code&gt;. Replies sent through Gmail's Send as aren't signed by your domain, so they can fail DMARC and get rejected. Set the policy to &lt;code&gt;p=none&lt;/code&gt; while Gmail still sends as your domain, then tighten it once it doesn't. Check what you have with &lt;code&gt;dig +short TXT _dmarc.yourdomain.com&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Email preview.&lt;/strong&gt; New sending domains store the content of sent messages for about seven days, on by default. If your replies are sensitive, turn off &lt;strong&gt;Enable email preview&lt;/strong&gt; under Email Sending &amp;gt; your domain &amp;gt; Settings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. It's a beta, aimed at transactional mail.&lt;/strong&gt; Cloudflare labels Email Sending as beta, and its FAQ says the service supports transactional email only and rules out marketing mail. One-to-one replies aren't marketing, but they aren't the use case its docs are built around either, so treat it as a gray area. Limits include 50 recipients and 25 MiB per message, plus a daily quota that starts conservative on new accounts and isn't published.&lt;/p&gt;

&lt;h2&gt;
  
  
  What replying through Cloudflare costs
&lt;/h2&gt;

&lt;p&gt;You need the &lt;strong&gt;Workers Paid&lt;/strong&gt; plan: $5 a month for the whole account, including 3,000 outbound emails a month, then $0.35 per 1,000. Ten thousand emails a month comes to $7.45. The allowance is per account, not per domain. On the free plan you can only send to verified destination addresses. Receiving through Email Routing stays free.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migration checklist
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;List your Send as addresses under Gmail &lt;strong&gt;Settings &amp;gt; Accounts and Import&lt;/strong&gt;. If you use catch-all, check your Sent folder too, since those addresses won't appear in the list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pick a path for each domain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set up sending authentication (SPF and DKIM) for the new path.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check DMARC before and after, and use &lt;code&gt;p=none&lt;/code&gt; while Gmail still sends as the domain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send test replies to a Gmail, an Outlook.com and an iCloud address, and confirm SPF, DKIM and DMARC pass.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remove the old Send as entries once replies go out the new way, then tighten DMARC.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Sources (read 29 November 2026)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://support.google.com/mail/answer/17101213" rel="noopener noreferrer"&gt;Google: Changes to third-party email account support in Gmail&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://support.google.com/mail/answer/16604719" rel="noopener noreferrer"&gt;Google: Changes to Gmailify and POP&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developers.cloudflare.com/email-service/api/send-emails/smtp/" rel="noopener noreferrer"&gt;Cloudflare: SMTP reference&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developers.cloudflare.com/changelog/post/2026-06-08-smtp-submission/" rel="noopener noreferrer"&gt;Cloudflare changelog: Authenticated SMTP submission, 8 June 2026&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developers.cloudflare.com/email-service/configuration/domains/" rel="noopener noreferrer"&gt;Cloudflare: Domain configuration, DMARC and Email preview&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developers.cloudflare.com/email-service/platform/limits/" rel="noopener noreferrer"&gt;Cloudflare: Limits&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developers.cloudflare.com/email-service/platform/pricing/" rel="noopener noreferrer"&gt;Cloudflare: Email Service pricing&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developers.cloudflare.com/email-service/reference/faq/" rel="noopener noreferrer"&gt;Cloudflare: Email Service FAQ&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://support.apple.com/guide/mail/mlhlp1106/mac" rel="noopener noreferrer"&gt;Apple: Verify an account's outgoing server in Mail on Mac&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://support.google.com/a/answer/15400543" rel="noopener noreferrer"&gt;Google Workspace: Business edition pricing&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://migadu.com/pricing" rel="noopener noreferrer"&gt;Migadu pricing&lt;/a&gt; and &lt;a href="https://www.fastmail.com/pricing" rel="noopener noreferrer"&gt;Fastmail pricing&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://support.apple.com/en-gb/102540" rel="noopener noreferrer"&gt;Apple: Custom Email Domain with iCloud Mail&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/gmail-is-ending-send-as-in-january-2027-what-it-means-for-cloudflare-email-routing-lyegr?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cloudflare</category>
      <category>customdomainemail</category>
      <category>dmarc</category>
      <category>emailrouting</category>
    </item>
    <item>
      <title>Connect Claude Code, Cursor, Windsurf, and VS Code to ZyVOP via MCP</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Mon, 30 Nov 2026 03:11:03 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/connect-claude-code-cursor-windsurf-and-vs-code-to-zyvop-via-mcp-5948</link>
      <guid>https://dev.to/sanjay_singh_1/connect-claude-code-cursor-windsurf-and-vs-code-to-zyvop-via-mcp-5948</guid>
      <description>&lt;p&gt;Most technical articles start inside a repository: a migration note, a benchmark script, or a README update. Moving that work into a blog usually means copying snippets into a browser, checking which syndication accounts are active, and rewriting social captions by hand.&lt;/p&gt;

&lt;p&gt;ZyVOP hosts a stateless Model Context Protocol (MCP) server at &lt;code&gt;https://zyvop.com/mcp&lt;/code&gt;. Your coding assistant connects over HTTPS using a personal developer token, with no local Node.js server to install or maintain.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note&lt;/p&gt;
&lt;p&gt;New posts created through MCP default to &lt;code&gt;draft&lt;/code&gt;. Your assistant can also schedule or publish posts, so ask for a draft whenever you want to review the article first.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  1. Generate a developer token
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sign in to ZyVOP and open &lt;strong&gt;Settings → Integrations&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find the &lt;strong&gt;ZyVOP API, CLI &amp;amp; MCP&lt;/strong&gt; section and click &lt;strong&gt;Generate Token&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy the token (&lt;code&gt;zv_&lt;/code&gt; followed by 48 hex characters).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The same token authenticates requests to the REST API, CLI, and MCP server. Tokens are hashed at rest and can be rotated or revoked from the same settings panel at any time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Warning&lt;/p&gt;
&lt;p&gt;Keep populated MCP config files out of Git. If you configure &lt;code&gt;.vscode/mcp.json&lt;/code&gt; inside a repository, add it to &lt;code&gt;.gitignore&lt;/code&gt; or use a personal config file outside the repo.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. Connect your client
&lt;/h2&gt;

&lt;p&gt;ZyVOP accepts JSON-RPC 2.0 requests over &lt;code&gt;HTTP POST&lt;/code&gt; and negotiates MCP protocol versions &lt;code&gt;2025-11-25&lt;/code&gt;, &lt;code&gt;2025-06-18&lt;/code&gt;, and &lt;code&gt;2025-03-26&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Claude Code
&lt;/h3&gt;

&lt;p&gt;Run the CLI command to add ZyVOP to your personal configuration (&lt;code&gt;~/.claude.json&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http --scope user zyvop https://zyvop.com/mcp \
  --header &lt;span class="s2"&gt;"Authorization: Bearer zv_your_token_here"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cursor (&lt;code&gt;~/.cursor/mcp.json&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"zyvop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://zyvop.com/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer zv_your_token_here"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windsurf (&lt;code&gt;~/.codeium/windsurf/mcp_config.json&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"zyvop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"serverUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://zyvop.com/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer zv_your_token_here"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  VS Code (&lt;code&gt;.vscode/mcp.json&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;VS Code uses a top-level &lt;code&gt;servers&lt;/code&gt; key. Cline and Roo Code use their own MCP setup screens and config formats.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"servers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"zyvop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://zyvop.com/mcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"headers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer zv_your_token_here"&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the connection directly with curl&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST https://zyvop.com/mcp \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Authorization: Bearer zv_your_token_here"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "zyvop_get_connected_platforms",
      "arguments": {}
    }
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Available MCP tools
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Access&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;zyvop_get_connected_platforms&lt;/td&gt;
&lt;td&gt;Read-only&lt;/td&gt;
&lt;td&gt;Lists connected channels and auto cross-post settings before you publish.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;zyvop_list_posts&lt;/td&gt;
&lt;td&gt;Read-only&lt;/td&gt;
&lt;td&gt;Lists your DRAFT, SCHEDULED, or PUBLISHED posts (limit 1–50, offset pagination).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;zyvop_create_post&lt;/td&gt;
&lt;td&gt;Write&lt;/td&gt;
&lt;td&gt;Creates a Markdown post (1–250,000 chars) as a draft, scheduled post, or published article.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;zyvop_get_account_analytics&lt;/td&gt;
&lt;td&gt;Read-only&lt;/td&gt;
&lt;td&gt;Returns lifetime account totals and an omnichannel view timeline (today, 24h, 7d, 30d, 90d, 12m, all).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;zyvop_get_post_analytics&lt;/td&gt;
&lt;td&gt;Read-only&lt;/td&gt;
&lt;td&gt;Returns available views, reactions, comments, and time-series data for one post UUID you own.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;zyvop_create_post&lt;/code&gt; parameters and guardrails
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Required&lt;/strong&gt;: &lt;code&gt;title&lt;/code&gt; (3–200 chars) and &lt;code&gt;markdown&lt;/code&gt; (1–250,000 chars, including code blocks, callouts, Mermaid diagrams, KaTeX math, and data charts).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lifecycle&lt;/strong&gt;: &lt;code&gt;publish_mode&lt;/code&gt; accepts &lt;code&gt;draft&lt;/code&gt; (default), &lt;code&gt;schedule&lt;/code&gt;, or &lt;code&gt;publish&lt;/code&gt;. Using &lt;code&gt;schedule&lt;/code&gt; requires a future ISO 8601 &lt;code&gt;scheduled_at&lt;/code&gt; timestamp.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AI disclosure&lt;/strong&gt;: Scheduling or publishing requires &lt;code&gt;ai_disclosure&lt;/code&gt; (&lt;code&gt;human_written&lt;/code&gt;, &lt;code&gt;ai_assisted&lt;/code&gt;, or &lt;code&gt;ai_generated&lt;/code&gt;). For &lt;code&gt;ai_assisted&lt;/code&gt; or &lt;code&gt;ai_generated&lt;/code&gt; posts, &lt;code&gt;ai_review_confirmed&lt;/code&gt; must also be &lt;code&gt;true&lt;/code&gt; after human review. Optional &lt;code&gt;ai_disclosure_note&lt;/code&gt; adds up to 500 characters of reader-facing context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Metadata&lt;/strong&gt;: Optional &lt;code&gt;excerpt&lt;/code&gt; (max 500 chars), &lt;code&gt;cover_image&lt;/code&gt; (URI), and &lt;code&gt;tags&lt;/code&gt; (up to 10 unique tags).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross-posting&lt;/strong&gt;: Pass connected destinations in &lt;code&gt;cross_post_to&lt;/code&gt;: &lt;code&gt;devto&lt;/code&gt;, &lt;code&gt;hashnode&lt;/code&gt;, &lt;code&gt;medium&lt;/code&gt;, &lt;code&gt;wordpress&lt;/code&gt;, &lt;code&gt;bluesky&lt;/code&gt;, &lt;code&gt;mastodon&lt;/code&gt;, &lt;code&gt;linkedin-profile&lt;/code&gt; (Free), &lt;code&gt;linkedin-page&lt;/code&gt; (Pro), or legacy &lt;code&gt;linkedin&lt;/code&gt;. You can include both &lt;code&gt;linkedin-profile&lt;/code&gt; and &lt;code&gt;linkedin-page&lt;/code&gt; with separate &lt;code&gt;linkedin_profile_caption&lt;/code&gt; and &lt;code&gt;linkedin_page_caption&lt;/code&gt; strings (up to 2,500 chars each; ZyVOP appends the article link). External copies run asynchronously after publication.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Recommended workflow
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNotj8FuwjAMhl_F8zk9TNqJw6QCQ5vENAQahxVUhdSl0dK4Styygnj3qdmO9vdZ_-8bGq4IZ1g7vphGB4H19uAB8mLNRjuYMHAAz0LxCFn2DPPiOg7clWeS0rD3ZISqsnNaag5tPE7n82Qu_k0TSAuVHUcBHaEKupakLZK2LPJeGg4QaLB0iWA9fI37j01ylsl5KTb9ydnYTGWiaajqHSX-kviqyOPoDZjAMWYpqSJnBwrjERW2FFptK5zdUBpqp48rqnXvBNXfZq-D1SdHcXJq9rLSrXUjzjDTXecoi2MUahXMnfXf79rs0rxiLwoOuKMzE3y-HVDBlk8srOCV3EBijVaQB6udgqh9zCIFW6NKITt7nbo8PnU_eL8rPJ0X7DjgDB8ujRXC-y90O461%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNotj8FuwjAMhl_F8zk9TNqJw6QCQ5vENAQahxVUhdSl0dK4Styygnj3qdmO9vdZ_-8bGq4IZ1g7vphGB4H19uAB8mLNRjuYMHAAz0LxCFn2DPPiOg7clWeS0rD3ZISqsnNaag5tPE7n82Qu_k0TSAuVHUcBHaEKupakLZK2LPJeGg4QaLB0iWA9fI37j01ylsl5KTb9ydnYTGWiaajqHSX-kviqyOPoDZjAMWYpqSJnBwrjERW2FFptK5zdUBpqp48rqnXvBNXfZq-D1SdHcXJq9rLSrXUjzjDTXecoi2MUahXMnfXf79rs0rxiLwoOuKMzE3y-HVDBlk8srOCV3EBijVaQB6udgqh9zCIFW6NKITt7nbo8PnU_eL8rPJ0X7DjgDB8ujRXC-y90O461%3Ftype%3Dpng" alt="Mermaid Diagram" width="1211" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A practical prompt pattern keeps the agent useful without letting it publish unreviewed text:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Ask the agent to check connected channels (&lt;code&gt;zyvop_get_connected_platforms&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have it save a draft (&lt;code&gt;publish_mode: "draft"&lt;/code&gt;) with separate LinkedIn captions if needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the draft in ZyVOP, verify code, claims, and disclosure, then publish or schedule.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  5. Security, rate limits, and retries
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Transport &amp;amp; headers&lt;/strong&gt;: Only &lt;code&gt;POST&lt;/code&gt; is accepted (&lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; return &lt;code&gt;405 Method Not Allowed&lt;/code&gt;). Responses include &lt;code&gt;Cache-Control: no-store&lt;/code&gt;, and browser-originated requests are checked against allowed origins.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rate limits&lt;/strong&gt;: Requests are capped at &lt;strong&gt;10 requests per 60 seconds&lt;/strong&gt; per developer token, with &lt;code&gt;X-RateLimit-Limit&lt;/code&gt;, &lt;code&gt;X-RateLimit-Remaining&lt;/code&gt;, &lt;code&gt;X-RateLimit-Reset&lt;/code&gt;, and &lt;code&gt;Retry-After&lt;/code&gt; headers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No blind retries on create&lt;/strong&gt;: &lt;code&gt;zyvop_create_post&lt;/code&gt; creates a new post on every call. If a network timeout drops a response, call &lt;code&gt;zyvop_list_posts&lt;/code&gt; first to check whether the draft already exists before retrying.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pre-publish checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Generate a &lt;code&gt;zv_&lt;/code&gt; developer token in &lt;strong&gt;Settings → Integrations&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect Claude Code, Cursor, Windsurf, or VS Code to &lt;code&gt;https://zyvop.com/mcp&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Confirm &lt;code&gt;zyvop_get_connected_platforms&lt;/code&gt; returns your active channels&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save your first post as a &lt;code&gt;draft&lt;/code&gt;, review it in ZyVOP, and set &lt;code&gt;ai_disclosure&lt;/code&gt; before publishing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/connect-claude-code-cursor-windsurf-and-vs-code-to-zyvop-via-mcp-i3bcd?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>developertools</category>
      <category>mcp</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Hardening zyvop.com's Deploy Path: SSH Keys, Firewalls, fail2ban, and Secrets I Can Rotate</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Sun, 29 Nov 2026 10:27:16 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/hardening-zyvopcoms-deploy-path-ssh-keys-firewalls-fail2ban-and-secrets-i-can-rotate-11li</link>
      <guid>https://dev.to/sanjay_singh_1/hardening-zyvopcoms-deploy-path-ssh-keys-firewalls-fail2ban-and-secrets-i-can-rotate-11li</guid>
      <description>&lt;p&gt;My last few &lt;a href="https://zyvop.com/what-i-monitor-on-zyvop-com-and-the-alerts-worth-waking-up-for-17wfz" rel="noopener noreferrer"&gt;posts&lt;/a&gt; built a pipeline that can change production on its own: GitHub Actions connects to a deploy host, which connects to every app server. That's convenient, and it also makes the pipeline the most powerful door into zyvop.com. This post is about making that door hard to open, and making sure that if a key or secret leaks anyway, the damage is small and fixable.&lt;/p&gt;

&lt;p&gt;I'm protecting against five things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Internet scanners&lt;/strong&gt; guessing SSH passwords all day.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A leaked CI key.&lt;/strong&gt; What can an attacker do with it?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A compromised app server.&lt;/strong&gt; How far can they get from there?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A secret that ends up in git, a log, or a chat message.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stale credentials&lt;/strong&gt; that nobody remembers to retire.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SSH:&lt;/strong&gt; keys only, verified with &lt;code&gt;sshd -T&lt;/code&gt;, and each hop of the deploy path uses its own key restricted to one forced command.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Firewalls:&lt;/strong&gt; default deny on every host. Docker bypasses ufw for published ports, so I bind those to private addresses and enforce sources at the cloud firewall.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;fail2ban:&lt;/strong&gt; useful for noise and defense in depth, but key-only SSH is what actually keeps people out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Secrets:&lt;/strong&gt; a documented home for each one, least-privilege database roles, files instead of environment variables, and an overlap-based rotation procedure.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All IPs below are placeholders, like in my earlier posts.&lt;/p&gt;




&lt;h2&gt;
  
  
  The path I'm protecting
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNqFUltv2jAU_itn5ylIjhQuWwsPk2CspRJQBBovMQ8mOSTWHDuyTVtW8d8nk5RN7GEvluzvdvzZ75iZnHCEB2Ves1JYD_M11wAA2yjdSie9sW7XgTgGjvcJg8GgzxHi-CvMJ-nciBz2Qgmdkd01uvmkIfeTJGmZ49Vqw3UDP85Sjo_Sz457GGdeGu047hqJcyWDg7EZ5ZCZqhI6bx2mQTWlWpkTlMZ5jm3adPY_aQhPOY7rGhzZF7IOord-5x-Hz4N-j0ElCysuU4HR6vQRP0mjlXG-sOQ6rS74_lFeibfgl_7dsAXX0zRaUy4vFg1v8T1KOS4IIpFXUsPTCoyF7WoZ5utcr3Zt4UN1izQN32Dgj1qTaimL52WIMjo8qdRF28a1h8XzslEOu0nCYNhNemG9vwtrr_tXEDKsyFZC5jh6R19SFX5QTgdxVB5Zc7IVVoq9Ihc4B6P9g6ikOuEIY1HXimJ3cp4qBhMl9c-FyDaX_YPRngHHDRWG4McTRwZrszfeMJiReiEvM8FgbKVQDJzQLnZk5QHZJWQjf4VZuoP6Dc9nhvvim1HG4gg_vZbSE55_A-7V3CE%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNqFUltv2jAU_itn5ylIjhQuWwsPk2CspRJQBBovMQ8mOSTWHDuyTVtW8d8nk5RN7GEvluzvdvzZ75iZnHCEB2Ves1JYD_M11wAA2yjdSie9sW7XgTgGjvcJg8GgzxHi-CvMJ-nciBz2Qgmdkd01uvmkIfeTJGmZ49Vqw3UDP85Sjo_Sz457GGdeGu047hqJcyWDg7EZ5ZCZqhI6bx2mQTWlWpkTlMZ5jm3adPY_aQhPOY7rGhzZF7IOord-5x-Hz4N-j0ElCysuU4HR6vQRP0mjlXG-sOQ6rS74_lFeibfgl_7dsAXX0zRaUy4vFg1v8T1KOS4IIpFXUsPTCoyF7WoZ5utcr3Zt4UN1izQN32Dgj1qTaimL52WIMjo8qdRF28a1h8XzslEOu0nCYNhNemG9vwtrr_tXEDKsyFZC5jh6R19SFX5QTgdxVB5Zc7IVVoq9Ihc4B6P9g6ikOuEIY1HXimJ3cp4qBhMl9c-FyDaX_YPRngHHDRWG4McTRwZrszfeMJiReiEvM8FgbKVQDJzQLnZk5QHZJWQjf4VZuoP6Dc9nhvvim1HG4gg_vZbSE55_A-7V3CE%3Ftype%3Dpng" alt="Mermaid Diagram" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything not drawn is blocked. Here's the same thing as a rule list, with who enforces each rule:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Host&lt;/th&gt;
&lt;th&gt;Port&lt;/th&gt;
&lt;th&gt;Allowed sources&lt;/th&gt;
&lt;th&gt;Enforced by&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Load balancer&lt;/td&gt;
&lt;td&gt;80, 443&lt;/td&gt;
&lt;td&gt;Anyone&lt;/td&gt;
&lt;td&gt;Cloud firewall and ufw&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App server&lt;/td&gt;
&lt;td&gt;3000 (published by Docker)&lt;/td&gt;
&lt;td&gt;Load balancer only&lt;/td&gt;
&lt;td&gt;Cloud firewall, plus a private-IP bind&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App server&lt;/td&gt;
&lt;td&gt;9102 (published by Docker)&lt;/td&gt;
&lt;td&gt;Monitoring server only&lt;/td&gt;
&lt;td&gt;Cloud firewall, plus a private-IP bind&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App server&lt;/td&gt;
&lt;td&gt;9100 (node_exporter on the host)&lt;/td&gt;
&lt;td&gt;Monitoring server&lt;/td&gt;
&lt;td&gt;ufw&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App server&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;Deploy host and my admin IP&lt;/td&gt;
&lt;td&gt;ufw, plus from= on the key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deploy host&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;Anyone, rate-limited (GitHub runner IPs vary)&lt;/td&gt;
&lt;td&gt;ufw limit, key-only auth, fail2ban&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postgres&lt;/td&gt;
&lt;td&gt;5432&lt;/td&gt;
&lt;td&gt;App servers and the deploy host&lt;/td&gt;
&lt;td&gt;Cloud firewall or ufw&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redis&lt;/td&gt;
&lt;td&gt;6379&lt;/td&gt;
&lt;td&gt;App servers&lt;/td&gt;
&lt;td&gt;Cloud firewall or ufw&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exporters&lt;/td&gt;
&lt;td&gt;9187, 9121&lt;/td&gt;
&lt;td&gt;Monitoring server&lt;/td&gt;
&lt;td&gt;ufw&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Monitoring UIs&lt;/td&gt;
&lt;td&gt;9090, 9093, 3000&lt;/td&gt;
&lt;td&gt;Nobody on the network (SSH tunnel only)&lt;/td&gt;
&lt;td&gt;Bound to 127.0.0.1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Step 1: SSH, keys only
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1a. Turn off passwords, and make sure it actually took
&lt;/h3&gt;

&lt;p&gt;I put my settings in a drop-in file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# /etc/ssh/sshd_config.d/00-hardening.conf
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
PubkeyAuthentication yes
AuthenticationMethods publickey
AllowUsers admin deploy
MaxAuthTries 3
LoginGraceTime 20
X11Forwarding no
AllowAgentForwarding no
AllowTcpForwarding no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The file name matters.&lt;/strong&gt; For each setting, &lt;code&gt;sshd&lt;/code&gt; keeps the &lt;strong&gt;first&lt;/strong&gt; value it reads, and on Debian and Ubuntu the &lt;code&gt;sshd_config.d/*.conf&lt;/code&gt; files are included at the &lt;em&gt;top&lt;/em&gt; of &lt;code&gt;sshd_config&lt;/code&gt;, in alphabetical order. Ubuntu cloud images and servers installed from the ISO can ship a &lt;code&gt;50-cloud-init.conf&lt;/code&gt; containing &lt;code&gt;PasswordAuthentication yes&lt;/code&gt;. A hardening file named &lt;code&gt;99-hardening.conf&lt;/code&gt; would silently lose to it, and so would the setting I edit in the main file. &lt;code&gt;00-&lt;/code&gt; sorts first, so mine wins.&lt;/p&gt;

&lt;p&gt;Debian also turns &lt;code&gt;X11Forwarding&lt;/code&gt; on by default, which is why I switch it off explicitly. On the monitoring server I use &lt;code&gt;AllowTcpForwarding local&lt;/code&gt; instead of &lt;code&gt;no&lt;/code&gt;, because that's how I reach Grafana through an SSH tunnel.&lt;/p&gt;

&lt;p&gt;I apply it carefully, so I can't lock myself out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo sshd -t                  &lt;span class="c"&gt;# syntax check: prints nothing when the config is valid&lt;/span&gt;
sudo systemctl reload ssh     &lt;span class="c"&gt;# the service is called "ssh" on Debian and Ubuntu&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before closing my current session, I open a &lt;strong&gt;second&lt;/strong&gt; one and confirm I can log in. Then I check what &lt;code&gt;sshd&lt;/code&gt; is &lt;em&gt;actually&lt;/em&gt; using, not what I think I told it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# check-ssh-hardening.sh: compare sshd's EFFECTIVE config with what I expect&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="kd"&gt;declare&lt;/span&gt; -A &lt;span class="nv"&gt;want&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;[&lt;/span&gt;passwordauthentication&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no
  &lt;span class="o"&gt;[&lt;/span&gt;kbdinteractiveauthentication&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no
  &lt;span class="o"&gt;[&lt;/span&gt;permitrootlogin&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no
  &lt;span class="o"&gt;[&lt;/span&gt;pubkeyauthentication&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;yes
  &lt;span class="o"&gt;[&lt;/span&gt;authenticationmethods&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;publickey
  &lt;span class="o"&gt;[&lt;/span&gt;x11forwarding&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no
  &lt;span class="o"&gt;[&lt;/span&gt;allowagentforwarding&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no
  &lt;span class="o"&gt;[&lt;/span&gt;allowtcpforwarding&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no
  &lt;span class="o"&gt;[&lt;/span&gt;maxauthtries&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3
  &lt;span class="o"&gt;[&lt;/span&gt;logingracetime&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;20
&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;effective&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(sudo sshd -T)"&lt;/span&gt;
&lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="k"&gt;for&lt;/span&gt; key &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"${!want[@]}"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;got&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(awk -v k="&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="s2"&gt;" '$1 == k { print $2; exit }' &amp;lt;&amp;lt;&amp;lt; "&lt;/span&gt;&lt;span class="nv"&gt;$effective&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$got"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"${want[$key]}"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"ok    $key = $got"&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"FAIL  $key = ${got:-&amp;lt;unset&amp;gt;} (want ${want[$key]})"&lt;/span&gt;
    &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="s2"&gt;"$status"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;sshd -T&lt;/code&gt; prints the effective configuration, so if a stray file overrides me, this script says so. I run it after every SSH change, and as part of my monitoring checks.&lt;/p&gt;

&lt;h3&gt;
  
  
  1b. People: one key per device, with a passphrase
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen -t ed25519 -a 100 -C &lt;span class="s2"&gt;"me@laptop-2026"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ed25519&lt;/code&gt; keys are short and fast, and &lt;code&gt;-a 100&lt;/code&gt; makes a stolen key file slower to crack. The comment names the owner and device, so I can tell whose key is whose in &lt;code&gt;authorized_keys&lt;/code&gt;, and I remove a key when a device is lost or retired.&lt;/p&gt;

&lt;h3&gt;
  
  
  1c. The deploy path: two hops, two keys, each restricted to one command
&lt;/h3&gt;

&lt;p&gt;In my CI/CD post, the CI key can only run a forced command on the deploy host. The second hop, from the deploy host to the app servers, deserves the same treatment. Otherwise a compromised deploy host could do anything on every app server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# deploy host, ~deploy/.ssh/authorized_keys: the CI key from my CI/CD post
restrict,command="/srv/zyvop/ci-entry.sh" ssh-ed25519 AAAA...ci-key... github-actions-deploy

# each app server, ~deploy/.ssh/authorized_keys: the deploy host's key
restrict,from="10.0.1.6",command="/srv/zyvop/app-entry.sh" ssh-ed25519 AAAA...deploy-host-key... deploy-host-to-apps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;restrict&lt;/code&gt; turns off forwarding and terminal allocation, &lt;code&gt;command=&lt;/code&gt; forces one script no matter what the client asks for, and &lt;code&gt;from=&lt;/code&gt; means the key only works from the deploy host's address. The CI key can't use &lt;code&gt;from=&lt;/code&gt;, because GitHub's runner addresses change.&lt;/p&gt;

&lt;p&gt;The app server's script validates its input the same way the deploy host's does:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# /srv/zyvop/app-entry.sh: the only thing the deploy host's key may run on an app server&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="nv"&gt;cmd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${SSH_ORIGINAL_COMMAND:-}"&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$cmd"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; *&lt;span class="s1"&gt;$'\n'&lt;/span&gt;* &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"unexpected input"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 2
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="nb"&gt;read&lt;/span&gt; -r action version extra &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"$cmd"&lt;/span&gt;
&lt;span class="nv"&gt;action&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${action:-}"&lt;/span&gt;
&lt;span class="nv"&gt;version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${version:-}"&lt;/span&gt;
&lt;span class="nv"&gt;extra&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${extra:-}"&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; -n &lt;span class="s2"&gt;"$extra"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;"$action"&lt;/span&gt; != &lt;span class="s2"&gt;"up"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; ! &lt;span class="s2"&gt;"$version"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;~ ^&lt;span class="o"&gt;[&lt;/span&gt;0-9a-f&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;40&lt;span class="o"&gt;}&lt;/span&gt;$ &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"not allowed"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 2
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;APP_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$version"&lt;/span&gt;
&lt;span class="nb"&gt;exec&lt;/span&gt; docker compose -f /srv/zyvop/compose.yml up -d --pull always
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then one line changes in &lt;code&gt;deploy-rolling.sh&lt;/code&gt; from my zero-downtime post. The deploy host no longer sends a raw &lt;code&gt;docker compose&lt;/code&gt; command, it just asks for a version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# before&lt;/span&gt;
ssh &lt;span class="s2"&gt;"$host"&lt;/span&gt; &lt;span class="s2"&gt;"APP_VERSION=$VERSION docker compose -f /srv/zyvop/compose.yml up -d --pull always"&lt;/span&gt;

&lt;span class="c"&gt;# after&lt;/span&gt;
ssh &lt;span class="s2"&gt;"$host"&lt;/span&gt; &lt;span class="s2"&gt;"up $VERSION"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;lb.sh&lt;/code&gt; gets the same treatment: its key on the load balancer is limited to a script that only accepts &lt;code&gt;drain&lt;/code&gt; and &lt;code&gt;enable&lt;/code&gt; for a known server.&lt;/p&gt;

&lt;p&gt;A few details about the &lt;code&gt;deploy&lt;/code&gt; account:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create it without a password:&lt;/strong&gt; &lt;code&gt;sudo adduser --disabled-password --gecos "" deploy&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Give it a real shell.&lt;/strong&gt; &lt;code&gt;sshd&lt;/code&gt; runs a forced command through the account's shell, so &lt;code&gt;nologin&lt;/code&gt; would break it. The restrictions come from the key, not the shell.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No&lt;/strong&gt; &lt;code&gt;sudo&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; But the account has to run Docker, and membership of the &lt;code&gt;docker&lt;/code&gt; group is root-equivalent. The forced commands are what keep that power on a leash, and rootless Docker is the stronger option if I want to go further.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pin the app servers' host keys&lt;/strong&gt; in the deploy host's &lt;code&gt;known_hosts&lt;/code&gt;, the same way I pinned the deploy host's key in GitHub.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 2: Firewalls, and the Docker catch
&lt;/h2&gt;

&lt;p&gt;My rule on every host is &lt;strong&gt;default deny incoming&lt;/strong&gt;, then open only what that host's job needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  The catch
&lt;/h3&gt;

&lt;p&gt;Docker publishes container ports by rewriting packets in the &lt;code&gt;nat&lt;/code&gt; table, before they reach the &lt;code&gt;INPUT&lt;/code&gt; chain where ufw's rules live. So a port Docker publishes is &lt;strong&gt;reachable no matter what ufw says&lt;/strong&gt;. Docker's own documentation says so. A &lt;code&gt;ufw deny 3000&lt;/code&gt; looks like protection and does nothing.&lt;/p&gt;

&lt;p&gt;My app container publishes ports 3000 (traffic) and 9102 (metrics). Three layers handle that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Publish on a specific private address, never on all interfaces.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ghcr.io/your-github-username/zyvop:${APP_VERSION}&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"10.0.1.11:3000:3000"&lt;/span&gt;   &lt;span class="c1"&gt;# reachable from the private network only
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"10.0.1.11:9102:9102"&lt;/span&gt;   &lt;span class="c1"&gt;# metrics, scraped by the monitoring server
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Restrict who can reach those ports at the cloud provider's firewall&lt;/strong&gt; (security groups or similar). That filter sits outside the server, so Docker can't bypass it. Port 3000 accepts the load balancer only, and 9102 accepts the monitoring server only.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If I ever need source filtering on the host itself,&lt;/strong&gt; Docker provides the &lt;code&gt;DOCKER-USER&lt;/code&gt; chain for exactly that. Packets there have already been NAT'd, so rules match the container's port, not the published one. I'd follow Docker's firewall documentation and not improvise.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I also run &lt;code&gt;node_exporter&lt;/code&gt; as a systemd service on the host, not in Docker, so ufw really does protect port 9100.&lt;/p&gt;

&lt;h3&gt;
  
  
  The app-server firewall
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# firewall-app.sh: host firewall for an app server. Run as root, with a second SSH session open.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="nv"&gt;ADMIN_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"203.0.113.10"&lt;/span&gt;        &lt;span class="c"&gt;# my home or VPN address (placeholder)&lt;/span&gt;
&lt;span class="nv"&gt;DEPLOY_HOST_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"10.0.1.6"&lt;/span&gt;
&lt;span class="nv"&gt;MONITOR_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"10.0.1.20"&lt;/span&gt;

ufw default deny incoming
ufw default allow outgoing

&lt;span class="c"&gt;# SSH rules go in BEFORE enabling: turning the firewall on can drop existing connections&lt;/span&gt;
ufw allow proto tcp from &lt;span class="s2"&gt;"$ADMIN_IP"&lt;/span&gt;       to any port 22
ufw allow proto tcp from &lt;span class="s2"&gt;"$DEPLOY_HOST_IP"&lt;/span&gt; to any port 22

&lt;span class="c"&gt;# node_exporter runs on the host, so ufw sees this traffic&lt;/span&gt;
ufw allow proto tcp from &lt;span class="s2"&gt;"$MONITOR_IP"&lt;/span&gt; to any port 9100

ufw --force &lt;span class="nb"&gt;enable&lt;/span&gt;
ufw status verbose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No ufw rules for 3000 and 9102.&lt;/strong&gt; They'd have no effect, and a rule that does nothing is worse than no rule, because it makes me think I'm covered.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;IPv6:&lt;/strong&gt; ufw only filters IPv6 if &lt;code&gt;IPV6=yes&lt;/code&gt; is set in &lt;code&gt;/etc/default/ufw&lt;/code&gt;. I check that, and make sure the cloud firewall covers IPv6 as well.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The deploy host is the exception
&lt;/h3&gt;

&lt;p&gt;GitHub-hosted runners connect from addresses I can't list, so port 22 on the deploy host has to accept connections from anywhere. I make that as safe as I can:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ufw limit 22/tcp comment &lt;span class="s1"&gt;'CI and admin SSH'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;limit&lt;/code&gt; allows connections but denies an address that attempts 6 or more in 30 seconds. Combined with key-only authentication, a forced command, and fail2ban, the exposed surface is small. If it still bothers me, I move to a self-hosted runner inside the private network and close port 22 to the internet entirely.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: fail2ban
&lt;/h2&gt;

&lt;p&gt;I'm honest about what fail2ban does here. With passwords disabled, a brute-force attacker &lt;strong&gt;cannot get in&lt;/strong&gt;, so it isn't what keeps people out. What it does is cut log noise and CPU load, and drop scanners after a few failed tries. It also protects other services later, like anything behind HTTP auth.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# /etc/fail2ban/jail.d/sshd.local
&lt;/span&gt;&lt;span class="k"&gt;[DEFAULT]&lt;/span&gt;
&lt;span class="na"&gt;ignoreip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;127.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mf"&gt;10.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="mf"&gt;203.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;113.10&lt;/span&gt;
&lt;span class="na"&gt;bantime&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1h&lt;/span&gt;
&lt;span class="na"&gt;findtime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10m&lt;/span&gt;
&lt;span class="na"&gt;maxretry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="na"&gt;bantime.increment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;banaction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ufw&lt;/span&gt;

&lt;span class="k"&gt;[sshd]&lt;/span&gt;
&lt;span class="na"&gt;enabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ignoreip&lt;/code&gt; keeps me, the private network, and the deploy host from being banned by accident.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;bantime.increment&lt;/code&gt; doubles the ban for repeat offenders.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;banaction = ufw&lt;/code&gt; makes bans go through ufw, so the two tools agree.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.local&lt;/code&gt; &lt;strong&gt;files override&lt;/strong&gt; &lt;code&gt;.conf&lt;/code&gt; &lt;strong&gt;files, and later files win.&lt;/strong&gt; That's the opposite of &lt;code&gt;sshd&lt;/code&gt;, where the first value wins, so I keep both rules straight.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I leave the log path and backend alone, so the distribution's defaults apply.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I don't trust it until I've seen it work. From another machine, I make six failed logins (&lt;code&gt;ssh -o PubkeyAuthentication=no admin@host&lt;/code&gt;), then run &lt;code&gt;sudo fail2ban-client status sshd&lt;/code&gt; to see the ban, and &lt;code&gt;sudo fail2ban-client set sshd unbanip &amp;lt;address&amp;gt;&lt;/code&gt; to lift it.&lt;/p&gt;

&lt;p&gt;One more caveat: if I ever misconfigure the CI key, the failed attempts from GitHub's runner address can get that address banned for an hour. If deploys suddenly time out after a key change, &lt;code&gt;fail2ban-client status sshd&lt;/code&gt; is the first place I look.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Where secrets live
&lt;/h2&gt;

&lt;p&gt;A secret I can't locate is a secret I can't rotate. This is my inventory:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Secret&lt;/th&gt;
&lt;th&gt;Lives in&lt;/th&gt;
&lt;th&gt;Who can read it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CI deploy key (private half)&lt;/td&gt;
&lt;td&gt;GitHub production environment secret&lt;/td&gt;
&lt;td&gt;Jobs on main after approval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CI deploy key (public half)&lt;/td&gt;
&lt;td&gt;Deploy host authorized_keys, forced command&lt;/td&gt;
&lt;td&gt;Nobody needs to, it's public&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deploy host to app servers key&lt;/td&gt;
&lt;td&gt;~deploy/.ssh/id_ed25519 on the deploy host, mode 0600&lt;/td&gt;
&lt;td&gt;The deploy user on that host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Registry read token&lt;/td&gt;
&lt;td&gt;~deploy/.docker/config.json on each server, mode 0600&lt;/td&gt;
&lt;td&gt;The deploy user&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App runtime secrets&lt;/td&gt;
&lt;td&gt;/srv/zyvop/app.env on app servers, root:deploy, mode 0640&lt;/td&gt;
&lt;td&gt;root and deploy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Migration database login&lt;/td&gt;
&lt;td&gt;/srv/zyvop/migrate.env on the deploy host, root:deploy, mode 0640&lt;/td&gt;
&lt;td&gt;root and deploy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Alert webhook URLs&lt;/td&gt;
&lt;td&gt;The monitoring server's alertmanager.yml&lt;/td&gt;
&lt;td&gt;Root and the Alertmanager user&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;And where they must &lt;strong&gt;never&lt;/strong&gt; be: in git, in an image layer or build argument, in CI logs, or in a chat message. Secrets pasted into any of those should be treated as leaked.&lt;/p&gt;

&lt;h3&gt;
  
  
  Give the app and the migrations different database logins
&lt;/h3&gt;

&lt;p&gt;The app doesn't need permission to drop tables, and migrations do. So they use different roles, and a compromised app server can't change the schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_app&lt;/span&gt; &lt;span class="no"&gt;NOLOGIN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                                    &lt;span class="c1"&gt;-- holds the app's privileges&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_app_a&lt;/span&gt; &lt;span class="no"&gt;LOGIN&lt;/span&gt; &lt;span class="no"&gt;PASSWORD&lt;/span&gt; &lt;span class="s1"&gt;'...'&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;-- a login that inherits them&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_migrate&lt;/span&gt; &lt;span class="no"&gt;LOGIN&lt;/span&gt; &lt;span class="no"&gt;PASSWORD&lt;/span&gt; &lt;span class="s1"&gt;'...'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                   &lt;span class="c1"&gt;-- owns the tables, runs migrations&lt;/span&gt;

&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;DEFAULT&lt;/span&gt; &lt;span class="no"&gt;PRIVILEGES&lt;/span&gt; &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_migrate&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="k"&gt;SCHEMA&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;
  &lt;span class="k"&gt;GRANT&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="no"&gt;TABLES&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="n"&gt;zyvop_app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;DEFAULT&lt;/span&gt; &lt;span class="no"&gt;PRIVILEGES&lt;/span&gt; &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_migrate&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="k"&gt;SCHEMA&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt;
  &lt;span class="k"&gt;GRANT&lt;/span&gt; &lt;span class="no"&gt;USAGE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="no"&gt;SEQUENCES&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="n"&gt;zyvop_app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;GRANT&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;INSERT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;UPDATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;ALL&lt;/span&gt; &lt;span class="no"&gt;TABLES&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="k"&gt;SCHEMA&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="n"&gt;zyvop_app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;GRANT&lt;/span&gt; &lt;span class="no"&gt;USAGE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;ALL&lt;/span&gt; &lt;span class="no"&gt;SEQUENCES&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="k"&gt;SCHEMA&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="n"&gt;zyvop_app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The tables need to be owned by &lt;code&gt;zyvop_migrate&lt;/code&gt; for that to hold, so I reassign existing ones with &lt;code&gt;ALTER TABLE ... OWNER TO zyvop_migrate&lt;/code&gt;. The app servers get &lt;code&gt;zyvop_app_a&lt;/code&gt;'s password in &lt;code&gt;app.env&lt;/code&gt;, and &lt;code&gt;migrate.sh&lt;/code&gt; from my CI/CD post changes one flag so it uses the migration login:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run --rm --env-file /srv/zyvop/migrate.env \
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;_a&lt;/code&gt; suffix is deliberate. It sets up zero-downtime password rotation, which I explain in the next step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Files, not environment variables
&lt;/h3&gt;

&lt;p&gt;Docker's documentation points out that environment variables are visible to every process in the container and can easily end up in logs. They also appear in &lt;code&gt;docker inspect&lt;/code&gt; for anyone with Docker access. Compose can mount a secret as a file under &lt;code&gt;/run/secrets/&lt;/code&gt; instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;DATABASE_PASSWORD_FILE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/run/secrets/db_password&lt;/span&gt;
    &lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;db_password&lt;/span&gt;

&lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db_password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/srv/zyvop/secrets/db_password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;_FILE&lt;/code&gt; suffix is only a convention. Some official images understand it, but my app has to read it itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;readFileSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:fs"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sb"&gt;`${name}_FILE`&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"utf8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Missing secret: set ${name}_FILE or ${name}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It accepts either form, so I can migrate secrets one at a time. The container's user has to be able to read the mounted file, and I confirm that with &lt;code&gt;docker compose exec app cat /run/secrets/db_password&lt;/code&gt; after the first deploy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Auditing permissions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# audit-secrets.sh: flag secret files with the wrong owner or permissions&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -uo pipefail
&lt;span class="nv"&gt;ROOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${ROOT:-}"&lt;/span&gt;      &lt;span class="c"&gt;# empty on a real server&lt;/span&gt;
&lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0

check&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;   &lt;span class="c"&gt;# path, expected mode, expected owner:group&lt;/span&gt;
  &lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$ROOT$1"&lt;/span&gt; &lt;span class="nv"&gt;mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$2"&lt;/span&gt; &lt;span class="nv"&gt;owner&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$3"&lt;/span&gt; got_mode got_owner
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; ! -e &lt;span class="s2"&gt;"$path"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"skip  $1 (not present)"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;return&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;
  &lt;span class="nv"&gt;got_mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(stat -c '%a' "&lt;/span&gt;&lt;span class="nv"&gt;$path&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
  &lt;span class="nv"&gt;got_owner&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(stat -c '%U:%G' "&lt;/span&gt;&lt;span class="nv"&gt;$path&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$got_mode"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"$mode"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="s2"&gt;"$got_owner"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"$owner"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"ok    $1 ($got_mode $got_owner)"&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"FAIL  $1 is $got_mode $got_owner, want $mode $owner"&lt;/span&gt;
    &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

check /srv/zyvop/app.env                 640 root:deploy
check /srv/zyvop/migrate.env             640 root:deploy
check /home/deploy/.ssh                  700 deploy:deploy
check /home/deploy/.ssh/authorized_keys  600 deploy:deploy
check /home/deploy/.ssh/id_ed25519       600 deploy:deploy
check /home/deploy/.docker/config.json   600 deploy:deploy
&lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="s2"&gt;"$status"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also turn on secret scanning for the repository where my plan allows it, and run a scanner such as gitleaks as a pre-commit hook, so a secret gets caught before it's pushed, not after.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5: Rotating secrets without breaking anything
&lt;/h2&gt;

&lt;p&gt;The rule I follow is &lt;strong&gt;overlap&lt;/strong&gt;. At every point, the old and new secrets are both valid, and I only revoke the old one after the new one is proven.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNpNkV1r2zAUhv_K6bnaQPbo1t2E0pGPhg66DhLaMaxeKPZxLCLrGOkkbhby34fl0O1SBz3P--rohCVXhBOsHfdlY4LA40p7AIBpofE6h2lVgTQET_e_IFIZSG434dPdh2HGrgL2BFGsc9Bz2MWPGl8hy-5gVmj8nMO6sR3YC1NR5_gIHGDfVUYoiaNwoAEbY2eJnp80fslhwRSBDhSO0li_TRFJ1VtpEu2pHyp803ge-TlkGTxxsqwKjUv7BlbUEBqo5QO9v4Y9jbU8X-wmguMo_8ok2W-KybYoNN7ksKID70bLz8fFZSfvxCJdvS80fs1hzr62oYX_d2UjBKr3kSqNr6iwpdAaW-HkhNJQO_xFRbXZO0E1Tl5MsGbjKA53avayNK11R5xgZrrOURaPUahVMHPW736Ycp3OS_aiQOOatkzw_F2jghVvWFjBA7kDiS2NgmmwximIxscsUrA1qhSytn-GLtc33Ruezwo32zk7DjjBq76xQnj-CyUIt1Y%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNpNkV1r2zAUhv_K6bnaQPbo1t2E0pGPhg66DhLaMaxeKPZxLCLrGOkkbhby34fl0O1SBz3P--rohCVXhBOsHfdlY4LA40p7AIBpofE6h2lVgTQET_e_IFIZSG434dPdh2HGrgL2BFGsc9Bz2MWPGl8hy-5gVmj8nMO6sR3YC1NR5_gIHGDfVUYoiaNwoAEbY2eJnp80fslhwRSBDhSO0li_TRFJ1VtpEu2pHyp803ge-TlkGTxxsqwKjUv7BlbUEBqo5QO9v4Y9jbU8X-wmguMo_8ok2W-KybYoNN7ksKID70bLz8fFZSfvxCJdvS80fs1hzr62oYX_d2UjBKr3kSqNr6iwpdAaW-HkhNJQO_xFRbXZO0E1Tl5MsGbjKA53avayNK11R5xgZrrOURaPUahVMHPW736Ycp3OS_aiQOOatkzw_F2jghVvWFjBA7kDiS2NgmmwximIxscsUrA1qhSytn-GLtc33Ruezwo32zk7DjjBq76xQnj-CyUIt1Y%3Ftype%3Dpng" alt="Mermaid Diagram" width="1060" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Secret&lt;/th&gt;
&lt;th&gt;How the overlap works&lt;/th&gt;
&lt;th&gt;My starting cadence&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CI deploy SSH key&lt;/td&gt;
&lt;td&gt;authorized_keys can hold both keys at once&lt;/td&gt;
&lt;td&gt;Every 90 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deploy host to apps key&lt;/td&gt;
&lt;td&gt;Same: both public keys in each app server's file&lt;/td&gt;
&lt;td&gt;Every 90 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Registry read token&lt;/td&gt;
&lt;td&gt;Create the new token, docker login on each server, then revoke the old one&lt;/td&gt;
&lt;td&gt;Every 90 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Session secret&lt;/td&gt;
&lt;td&gt;An array of secrets, newest first (below)&lt;/td&gt;
&lt;td&gt;Every 6 to 12 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JWT signing key&lt;/td&gt;
&lt;td&gt;Publish both verification keys with key IDs, sign with the new one, drop the old after tokens expire&lt;/td&gt;
&lt;td&gt;Every 6 to 12 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database login&lt;/td&gt;
&lt;td&gt;Two interchangeable logins on one privilege role&lt;/td&gt;
&lt;td&gt;Every 6 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Webhook URLs and API keys&lt;/td&gt;
&lt;td&gt;Regenerate at the provider, update the config, reload&lt;/td&gt;
&lt;td&gt;When leaked, or yearly&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The cadences are my starting points, not standards. The real triggers are a suspected leak, a lost device, or someone leaving.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rotating the CI key
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. New key pair on my machine. No passphrase: only CI uses it, and a forced command limits it.&lt;/span&gt;
ssh-keygen -t ed25519 -N &lt;span class="s2"&gt;""&lt;/span&gt; -C &lt;span class="s2"&gt;"github-actions-deploy-2027-01"&lt;/span&gt; -f ./ci-key-new

&lt;span class="c"&gt;# 2. On the deploy host: add the NEW public key to authorized_keys, with the same options line,&lt;/span&gt;
&lt;span class="c"&gt;#    next to the old one. Both work during the overlap.&lt;/span&gt;

&lt;span class="c"&gt;# 3. Point GitHub at the new private key (environment secret)&lt;/span&gt;
gh secret &lt;span class="nb"&gt;set&lt;/span&gt; DEPLOY_SSH_KEY --env production &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; ./ci-key-new

&lt;span class="c"&gt;# 4. Run a deploy (or the rollback workflow) and confirm it succeeds.&lt;/span&gt;

&lt;span class="c"&gt;# 5. Remove the OLD line from authorized_keys, then confirm the old key is refused.&lt;/span&gt;

&lt;span class="c"&gt;# 6. Delete the local copy&lt;/span&gt;
rm ./ci-key-new ./ci-key-new.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;gh&lt;/code&gt; encrypts the value locally before sending it to GitHub. The new key is the one that gets registered at step 3, so nothing breaks if I need to stop after step 2.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rotating the session secret with zero logouts
&lt;/h3&gt;

&lt;p&gt;Back in my scaling post, the session secret was a single value. Changing it logs everyone out. The &lt;code&gt;express-session&lt;/code&gt; docs describe the fix: pass an array, where only the first element signs new cookies, and all of them verify existing ones.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;secret&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./secret.js"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// SESSION_SECRETS="newest,previous": comma-separated, newest first&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sessionSecrets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SESSION_SECRETS"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;","&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;session&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sessionSecrets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="cm"&gt;/* ...the rest as before... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To rotate: put the new secret &lt;strong&gt;first&lt;/strong&gt;, keep the old one second, deploy, and drop the old one only after the longest session lifetime (my cookie's &lt;code&gt;maxAge&lt;/code&gt;) has passed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rotating the database login
&lt;/h3&gt;

&lt;p&gt;This is where the &lt;code&gt;_a&lt;/code&gt; login pays off. I create a second login on the same privilege role, point the app at it, and retire the first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_app_b&lt;/span&gt; &lt;span class="no"&gt;LOGIN&lt;/span&gt; &lt;span class="no"&gt;PASSWORD&lt;/span&gt; &lt;span class="s1"&gt;'...'&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;-- update app.env with zyvop_app_b's credentials, roll the deploy, then:&lt;/span&gt;
&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="no"&gt;ROLE&lt;/span&gt; &lt;span class="n"&gt;zyvop_app_a&lt;/span&gt; &lt;span class="no"&gt;NOLOGIN&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I never change the password of the login that's currently in use, because during a rolling deploy some servers would still hold the old password and start failing their next connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  When I suspect a leak
&lt;/h3&gt;

&lt;p&gt;The overlap rule bends for emergencies: &lt;strong&gt;revoke first, then replace.&lt;/strong&gt; A short disruption is better than a leaked credential staying valid. I revoke the exposed secret, issue a new one, deploy, and then check the logs for anything the old one did.&lt;/p&gt;




&lt;h2&gt;
  
  
  Verify from the outside
&lt;/h2&gt;

&lt;p&gt;Hardening isn't done until I've tested it the way an attacker would:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Expected result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;nmap -Pn -p- &amp;lt;each public IP&amp;gt; from outside my network&lt;/td&gt;
&lt;td&gt;Only 80 and 443 on the load balancer, and 22 on the deploy host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ssh -o PubkeyAuthentication=no admin@host&lt;/td&gt;
&lt;td&gt;Permission denied (publickey)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The CI key running something other than a deploy&lt;/td&gt;
&lt;td&gt;not allowed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;./check-ssh-hardening.sh on every server&lt;/td&gt;
&lt;td&gt;Every line says ok&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sudo ufw status verbose&lt;/td&gt;
&lt;td&gt;Default deny incoming, and only the rules I wrote&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sudo fail2ban-client status sshd&lt;/td&gt;
&lt;td&gt;The jail is running&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;./audit-secrets.sh&lt;/td&gt;
&lt;td&gt;Every line says ok or skip&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;docker compose ps on an app server&lt;/td&gt;
&lt;td&gt;Ports bound to 10.0.1.x, never 0.0.0.0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The external scan matters most, because Docker, ufw, and the cloud firewall all affect the result, and only a test from outside accounts for all three.&lt;/p&gt;




&lt;h2&gt;
  
  
  Mistakes I'm trying not to make
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Naming the SSH drop-in&lt;/strong&gt; &lt;code&gt;99-something&lt;/code&gt;&lt;strong&gt;,&lt;/strong&gt; so a cloud-init file wins.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Trusting&lt;/strong&gt; &lt;code&gt;ufw status&lt;/code&gt; &lt;strong&gt;for Docker ports.&lt;/strong&gt; It doesn't see them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enabling the firewall before the SSH rule,&lt;/strong&gt; and locking myself out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Closing my only SSH session before testing a second one.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using the same key for CI and for the deploy host.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Putting secrets in environment variables, git, or image layers.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rotating by replacing.&lt;/strong&gt; Revoking the old secret before the new one is proven causes outages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Never practicing a rotation,&lt;/strong&gt; so the first time is an emergency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Giving the app a database login that can drop tables.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hardening once and never checking again.&lt;/strong&gt; Drift happens, so the check scripts run on a schedule.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  My hardening checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;00-hardening.conf&lt;/code&gt; sets key-only SSH, and &lt;code&gt;sshd -T&lt;/code&gt; confirms the effective values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No root login, &lt;code&gt;AllowUsers&lt;/code&gt; set, forwarding off (except where I need tunnels)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One passphrase-protected key per person and device, with a labelled comment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CI key restricted by &lt;code&gt;restrict&lt;/code&gt; and a forced command that validates its input&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploy host to app servers key restricted by &lt;code&gt;restrict&lt;/code&gt;, &lt;code&gt;from=&lt;/code&gt;, and its own forced command&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;deploy&lt;/code&gt; account has no password, no &lt;code&gt;sudo&lt;/code&gt;, and a real shell&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Default deny incoming on every host, with SSH rules added before &lt;code&gt;enable&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker ports published on private addresses, with sources restricted at the cloud firewall&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ufw limit&lt;/code&gt; on the deploy host's public SSH port&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;fail2ban running, my IPs in &lt;code&gt;ignoreip&lt;/code&gt;, and a ban actually tested&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every secret has a documented home, and none live in git, images, or logs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The app and migrations use separate database roles&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Secrets read from files where the app supports it&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rotation procedure written down and practiced for each secret&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;External port scan run, and &lt;code&gt;audit-secrets.sh&lt;/code&gt; and &lt;code&gt;check-ssh-hardening.sh&lt;/code&gt; passing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Hardening is mostly about &lt;strong&gt;limiting what each credential can do and knowing where it lives&lt;/strong&gt;. A leaked CI key can run one validated command, not a shell. A compromised app server can't change the schema. A rotated secret doesn't cause an outage. None of that stops every attack, but together they turn a catastrophic breach into a contained one, and a 3 a.m. emergency into a procedure I've already practiced.&lt;/p&gt;

&lt;p&gt;What's still missing is the thing that makes all of this recoverable when it goes wrong: backups I've actually restored. That's the next post.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What's the most surprising thing you've found exposed on one of your own servers? Tell me in the comments and I'll cover it in a follow-up.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/hardening-zyvop-com-s-deploy-path-ssh-keys-firewalls-fail2ban-and-secrets-i-can-rotate-9ew5u?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>fail2ban</category>
      <category>secretsmanagement</category>
      <category>serverhardening</category>
    </item>
    <item>
      <title>What I Monitor on zyvop.com, and the Alerts Worth Waking Up For</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Sat, 28 Nov 2026 05:34:57 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/what-i-monitor-on-zyvopcom-and-the-alerts-worth-waking-up-for-31l9</link>
      <guid>https://dev.to/sanjay_singh_1/what-i-monitor-on-zyvopcom-and-the-alerts-worth-waking-up-for-31l9</guid>
      <description>&lt;p&gt;The CI/CD pipeline from my last &lt;a href="https://zyvop.com/keeping-users-signed-in-during-docker-deployments-sj4qx" rel="noopener noreferrer"&gt;post&lt;/a&gt; can tell me a deploy &lt;em&gt;finished&lt;/em&gt;. It can't tell me the site is still healthy an hour later, or that a slow query is quietly making every page worse. Monitoring fills that gap.&lt;/p&gt;

&lt;p&gt;I want two things from it: to hear about problems before visitors tell me, and to be woken up only when waking up is worth it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I watch four signals: &lt;strong&gt;latency, traffic, errors, saturation&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The app exports one request histogram labelled by route, status, and &lt;strong&gt;version&lt;/strong&gt;. Exporters cover the servers, Postgres, Redis, and an external probe.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I alert on &lt;strong&gt;symptoms visitors feel&lt;/strong&gt;. A page has to be urgent and actionable. Everything else becomes a ticket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every deploy &lt;strong&gt;watches its own version's&lt;/strong&gt; error rate and latency before I trust it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The four signals
&lt;/h2&gt;

&lt;p&gt;Google's SRE book calls these the four golden signals, and they cover most of what matters for a web service.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;The question&lt;/th&gt;
&lt;th&gt;Where it comes from&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Latency&lt;/td&gt;
&lt;td&gt;How long do requests take?&lt;/td&gt;
&lt;td&gt;Percentiles (p95, p99) from the request histogram&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traffic&lt;/td&gt;
&lt;td&gt;How much demand is there?&lt;/td&gt;
&lt;td&gt;Request rate from the same histogram&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Errors&lt;/td&gt;
&lt;td&gt;What share of requests fail?&lt;/td&gt;
&lt;td&gt;5xx ratio from the same histogram, plus an external probe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Saturation&lt;/td&gt;
&lt;td&gt;How full is the most constrained resource?&lt;/td&gt;
&lt;td&gt;CPU, memory, disk, database connections, Redis memory, event loop lag&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I watch percentiles, not averages. A few very slow requests barely move the mean, but they're exactly what unhappy visitors experience.&lt;/p&gt;

&lt;p&gt;Metrics tell me &lt;em&gt;that&lt;/em&gt; something is wrong. Logs tell me &lt;em&gt;why&lt;/em&gt;, so I keep the centralized logging from my scaling post alongside this.&lt;/p&gt;




&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNqFk2FP2zAQhv_K7T4VKREUDW2rNqRkQJnWQtQyNCmupktyTaw6dmS7hYL471OSstGxaf722s_re88nP2JuCsYRLpW5yyuyHiYzoQEAbgfprXTSG-sWBxCGpzCJ04mhAjJSpHO2i243ShKhe4tbZ6WlpoKbaDY-v5mnAue5pYbBky3ZO4GLnmxXlCSpwCtTMFDTwOjD8Oj4Y2YPTwe-sszg2G7YuoM909X12XkqUJuCf_B9Y6xn21mP_mtNxt9TgY1xvrTs9tzv3-2Rs7OWtFzIfex4-AtjXbzqenp9lQqcGt0-mtTlLgYMGis35Bk0-ztjV3_ESgcCE2tq9hWvncCDF4dxnArMFOWrzNzvZRme7D_mNI0UW1-TppLti5NxOra0JE2vkycQhiDQdTNywBu2WxieOIHdZHdT_CvbWJMxWHZr5Z_5OO7ROO7ZjnFwWDEpXz3sqEn8-8JTiKa9Gncq6UU03RVrE0m__dRQyTt7cpkmldEM1La7-IfBy3zF_rmPr-lNpyGvSGtWCwywZluTLHD0iL7iuv0DBS9prTwG_c4tWUmZYtcyS6P9BdVSbXGEITWN4tBtnec6gFhJvZpSPu_0hdE-AIFzLg3Dty8CA5iZzHgTwCWrDXuZUwCRlaQCcKRd6NjKJQZdkbl8aLMM3zb3-PQUYFZ-NspYHOGbu0p6xqefvnYmdw%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNqFk2FP2zAQhv_K7T4VKREUDW2rNqRkQJnWQtQyNCmupktyTaw6dmS7hYL471OSstGxaf722s_re88nP2JuCsYRLpW5yyuyHiYzoQEAbgfprXTSG-sWBxCGpzCJ04mhAjJSpHO2i243ShKhe4tbZ6WlpoKbaDY-v5mnAue5pYbBky3ZO4GLnmxXlCSpwCtTMFDTwOjD8Oj4Y2YPTwe-sszg2G7YuoM909X12XkqUJuCf_B9Y6xn21mP_mtNxt9TgY1xvrTs9tzv3-2Rs7OWtFzIfex4-AtjXbzqenp9lQqcGt0-mtTlLgYMGis35Bk0-ztjV3_ESgcCE2tq9hWvncCDF4dxnArMFOWrzNzvZRme7D_mNI0UW1-TppLti5NxOra0JE2vkycQhiDQdTNywBu2WxieOIHdZHdT_CvbWJMxWHZr5Z_5OO7ROO7ZjnFwWDEpXz3sqEn8-8JTiKa9Gncq6UU03RVrE0m__dRQyTt7cpkmldEM1La7-IfBy3zF_rmPr-lNpyGvSGtWCwywZluTLHD0iL7iuv0DBS9prTwG_c4tWUmZYtcyS6P9BdVSbXGEITWN4tBtnec6gFhJvZpSPu_0hdE-AIFzLg3Dty8CA5iZzHgTwCWrDXuZUwCRlaQCcKRd6NjKJQZdkbl8aLMM3zb3-PQUYFZ-NspYHOGbu0p6xqefvnYmdw%3Ftype%3Dpng" alt="Mermaid Diagram" width="1491" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prometheus, Alertmanager, and Grafana run on their own small server&lt;/strong&gt;, so a problem on the app servers can't take the monitoring down with it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;None of them face the internet.&lt;/strong&gt; Prometheus has no login by default, so I keep all three on the private network or behind a VPN.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prometheus keeps 15 days of data unless I change the retention setting, which is plenty for diagnosing recent problems.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 1: Instrument the app
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:http"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"prom-client"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collectDefaultMetrics&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// process_* and nodejs_* metrics, including event loop lag&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;VERSION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;APP_VERSION&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// short git SHA&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;httpDuration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Histogram&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http_request_duration_seconds"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"HTTP request duration in seconds"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;labelNames&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"method"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"route"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;buckets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.025&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;2.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;metricsMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;stop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;httpDuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startTimer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"finish"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;route&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;baseUrl&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"unmatched"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;VERSION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// A separate internal port, so /metrics is never reachable through the load balancer&lt;/span&gt;
&lt;span class="n"&gt;http&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"/metrics"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;register&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contentType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;register&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;statusCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9102&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;METRICS_HOST&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I register &lt;code&gt;app.use(metricsMiddleware)&lt;/code&gt; before my routes. A few details matter here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;One histogram is enough.&lt;/strong&gt; Its &lt;code&gt;_count&lt;/code&gt; series is my request counter, so it gives me traffic and error ratios as well as latency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Label by route pattern, never by raw URL.&lt;/strong&gt; &lt;code&gt;/users/:id&lt;/code&gt; is one series. &lt;code&gt;/users/48213&lt;/code&gt; is a new series for every user, and enough of those will overwhelm Prometheus. The same goes for user IDs, emails, and IP addresses. Unmatched requests (404s from scanners) all share the single label &lt;code&gt;unmatched&lt;/code&gt; so they can't blow up the label count either.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;await register.metrics()&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; It has returned a promise since prom-client v13, and forgetting the &lt;code&gt;await&lt;/code&gt; serves &lt;code&gt;[object Promise]&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set the&lt;/strong&gt; &lt;code&gt;Content-Type&lt;/code&gt;&lt;strong&gt;.&lt;/strong&gt; Prometheus 3 fails a scrape when the header is missing or unrecognised, instead of guessing like version 2 did. &lt;code&gt;register.contentType&lt;/code&gt; is the right value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;version&lt;/code&gt; &lt;strong&gt;is the 7-character git SHA&lt;/strong&gt;, taken from the same &lt;code&gt;APP_VERSION&lt;/code&gt; the pipeline bakes into the image. That's what lets me compare versions side by side. Each deploy creates a fresh set of series, which is fine at my scale. If I ever deploy many times a day, I'd move the version to a single &lt;code&gt;app_info&lt;/code&gt; metric and join on it instead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;METRICS_HOST&lt;/code&gt; is the server's private address. I firewall port 9102 so only the monitoring server can reach it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 2: Scrape everything
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Exporter&lt;/th&gt;
&lt;th&gt;Port&lt;/th&gt;
&lt;th&gt;What it gives me&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;node_exporter (every app server)&lt;/td&gt;
&lt;td&gt;9100&lt;/td&gt;
&lt;td&gt;CPU, memory, disk, network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;postgres_exporter&lt;/td&gt;
&lt;td&gt;9187&lt;/td&gt;
&lt;td&gt;pg_up, connection counts and limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;redis_exporter&lt;/td&gt;
&lt;td&gt;9121&lt;/td&gt;
&lt;td&gt;redis_up, memory used and limit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;blackbox_exporter&lt;/td&gt;
&lt;td&gt;9115&lt;/td&gt;
&lt;td&gt;An HTTPS probe of the public site, plus certificate expiry&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# prometheus.yml
&lt;/span&gt;&lt;span class="na"&gt;global&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;scrape_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;15s&lt;/span&gt;
  &lt;span class="na"&gt;evaluation_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;15s&lt;/span&gt;

&lt;span class="na"&gt;rule_files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;alerts.yml&lt;/span&gt;

&lt;span class="na"&gt;alerting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;alertmanagers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;static_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"localhost:9093"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;scrape_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;job_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;zyvop-app&lt;/span&gt;
    &lt;span class="na"&gt;static_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"10.0.1.11:9102"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"10.0.1.12:9102"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"10.0.1.13:9102"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;job_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;node&lt;/span&gt;
    &lt;span class="na"&gt;static_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"10.0.1.11:9100"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"10.0.1.12:9100"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"10.0.1.13:9100"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;job_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;
    &lt;span class="na"&gt;static_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"10.0.1.31:9187"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;job_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis&lt;/span&gt;
    &lt;span class="na"&gt;static_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"10.0.1.32:9121"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;job_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;blackbox-http&lt;/span&gt;
    &lt;span class="na"&gt;metrics_path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/probe&lt;/span&gt;
    &lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;http_2xx&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;static_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"https://zyvop.com/healthz"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;relabel_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;source_labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;__address__&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="na"&gt;target_label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;__param_target&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;source_labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;__param_target&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="na"&gt;target_label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;instance&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;target_label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;__address__&lt;/span&gt;
        &lt;span class="na"&gt;replacement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localhost:9115&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# blackbox.yml
&lt;/span&gt;&lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;http_2xx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;prober&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http&lt;/span&gt;
    &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
    &lt;span class="na"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;GET&lt;/span&gt;
      &lt;span class="na"&gt;fail_if_not_ssl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The IPs are placeholders. The probe fetches the real public URL, so it exercises DNS, TLS, the CDN, and the load balancer together, which is what a visitor's request does. It also exposes the certificate's expiry date.&lt;/p&gt;

&lt;p&gt;I run the probe from a server that doesn't share a network with the app if I can. A probe that lives in the same data center can't see a network problem that cuts the site off from everyone else.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Alerts that earn their place
&lt;/h2&gt;

&lt;p&gt;My rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Alert on symptoms, not causes.&lt;/strong&gt; "Error rate above 5%" is something visitors feel. "CPU at 85%" might mean nothing. Causes belong on dashboards.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A page must be urgent, actionable, and real.&lt;/strong&gt; If it can wait until morning, it's a ticket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use&lt;/strong&gt; &lt;code&gt;for:&lt;/code&gt; so a ten-second blip doesn't wake me.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Alert&lt;/th&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Fires when&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SiteDown&lt;/td&gt;
&lt;td&gt;Page&lt;/td&gt;
&lt;td&gt;The external probe fails for 2 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HighErrorRate&lt;/td&gt;
&lt;td&gt;Page&lt;/td&gt;
&lt;td&gt;More than 5% of requests are 5xx for 5 minutes (with a traffic floor)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HighLatency&lt;/td&gt;
&lt;td&gt;Page&lt;/td&gt;
&lt;td&gt;p95 latency is above 1.5 seconds for 10 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;InstanceDown&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;A server stops reporting for 5 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DiskFillingUp&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;A disk is predicted to fill within 24 hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HighCPU&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;CPU is above 90% for 15 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LowMemory&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;Less than 10% of memory is available for 15 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DatabaseDown&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;Postgres isn't answering the exporter for 2 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DatabaseConnectionsHigh&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;Connections are above 80% of the limit for 10 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RedisDown&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;Redis isn't answering the exporter for 2 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RedisMemoryHigh&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;Redis is above 90% of its maxmemory for 10 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CertificateExpiringSoon&lt;/td&gt;
&lt;td&gt;Ticket&lt;/td&gt;
&lt;td&gt;The certificate expires within 14 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Watchdog&lt;/td&gt;
&lt;td&gt;Heartbeat&lt;/td&gt;
&lt;td&gt;Always. It proves the alerting path is alive&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;DatabaseDown&lt;/code&gt; and &lt;code&gt;RedisDown&lt;/code&gt; are tickets because if either goes down, the error-rate page fires anyway. The ticket just tells me why.&lt;/p&gt;

&lt;p&gt;The thresholds are starting points. I tune them after a week of looking at what normal actually is.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# alerts.yml
&lt;/span&gt;&lt;span class="na"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;zyvop-pages&lt;/span&gt;
    &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SiteDown&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;probe_success{job="blackbox-http"} == 0&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;page&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"zyvop.com is failing external health checks"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HighErrorRate&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;(&lt;/span&gt;
            &lt;span class="s"&gt;sum(rate(http_request_duration_seconds_count{status=~"5.."}[5m]))&lt;/span&gt;
            &lt;span class="s"&gt;/&lt;/span&gt;
            &lt;span class="s"&gt;sum(rate(http_request_duration_seconds_count[5m]))&lt;/span&gt;
          &lt;span class="s"&gt;) &amp;gt; 0.05&lt;/span&gt;
          &lt;span class="s"&gt;and&lt;/span&gt;
          &lt;span class="s"&gt;sum(rate(http_request_duration_seconds_count[5m])) &amp;gt; 0.1&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;page&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"More than 5% of requests are failing"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HighLatency&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;histogram_quantile(0.95,&lt;/span&gt;
            &lt;span class="s"&gt;sum by (le) (rate(http_request_duration_seconds_bucket[5m]))&lt;/span&gt;
          &lt;span class="s"&gt;) &amp;gt; 1.5&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;page&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"p95 latency has been above 1.5 seconds"&lt;/span&gt;

  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;zyvop-tickets&lt;/span&gt;
    &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;InstanceDown&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;up{job=~"zyvop-app|node"} == 0&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ $labels.instance }} ({{ $labels.job }}) has stopped reporting"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;DiskFillingUp&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;predict_linear(node_filesystem_avail_bytes{fstype!~"tmpfs|overlay|squashfs"}[6h], 24 * 3600) &amp;lt; 0&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ $labels.instance }}:{{ $labels.mountpoint }} is predicted to fill within 24 hours"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HighCPU&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) &amp;gt; 0.9&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;15m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ $labels.instance }} CPU has been above 90%"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;LowMemory&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes &amp;lt; 0.10&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;15m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ $labels.instance }} has under 10% memory available"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;DatabaseDown&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pg_up == 0&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Postgres is not responding"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;DatabaseConnectionsHigh&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;sum by (instance) (pg_stat_activity_count)&lt;/span&gt;
          &lt;span class="s"&gt;/ max by (instance) (pg_settings_max_connections) &amp;gt; 0.8&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Postgres connections are above 80% of the limit"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;RedisDown&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis_up == 0&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Redis is not responding"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;RedisMemoryHigh&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;redis_memory_used_bytes / redis_memory_max_bytes &amp;gt; 0.9&lt;/span&gt;
          &lt;span class="s"&gt;and on (instance) redis_memory_max_bytes &amp;gt; 0&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Redis is above 90% of maxmemory"&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;CertificateExpiringSoon&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;probe_ssl_earliest_cert_expiry{job="blackbox-http"} - time() &amp;lt; 14 * 24 * 3600&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1h&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"The TLS certificate expires in less than 14 days"&lt;/span&gt;

  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;zyvop-watchdog&lt;/span&gt;
    &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Watchdog&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vector(1)&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;heartbeat&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Always firing. If this stops arriving, alerting is broken."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two expressions are worth a second look:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;HighErrorRate&lt;/code&gt; &lt;strong&gt;has a traffic floor&lt;/strong&gt; (&lt;code&gt;&amp;gt; 0.1&lt;/code&gt; requests per second). Without it, two failed requests out of three at 3 a.m. would be a "100% error rate" page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;RedisMemoryHigh&lt;/code&gt; &lt;strong&gt;has the&lt;/strong&gt; &lt;code&gt;redis_memory_max_bytes &amp;gt; 0&lt;/code&gt; &lt;strong&gt;guard.&lt;/strong&gt; When no &lt;code&gt;maxmemory&lt;/code&gt; is configured, the exporter reports 0, the division returns infinity, and the alert would fire forever.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 4: Route alerts to the right place
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# alertmanager.yml
&lt;/span&gt;&lt;span class="na"&gt;route&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
  &lt;span class="na"&gt;group_by&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;alertname&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;group_wait&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30s&lt;/span&gt;
  &lt;span class="na"&gt;group_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5m&lt;/span&gt;
  &lt;span class="na"&gt;repeat_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;24h&lt;/span&gt;
  &lt;span class="na"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;matchers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'severity="page"'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;page&lt;/span&gt;
      &lt;span class="na"&gt;group_wait&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10s&lt;/span&gt;
      &lt;span class="na"&gt;repeat_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1h&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;matchers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'severity="heartbeat"'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;heartbeat&lt;/span&gt;
      &lt;span class="na"&gt;group_wait&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;0s&lt;/span&gt;
      &lt;span class="na"&gt;repeat_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5m&lt;/span&gt;

&lt;span class="na"&gt;receivers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;page&lt;/span&gt;
    &lt;span class="na"&gt;webhook_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://example.com/hooks/page"&lt;/span&gt;          &lt;span class="c1"&gt;# my phone-alert service
&lt;/span&gt;        &lt;span class="na"&gt;send_resolved&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ticket&lt;/span&gt;
    &lt;span class="na"&gt;webhook_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://example.com/hooks/ticket"&lt;/span&gt;        &lt;span class="c1"&gt;# a chat channel or ticket queue
&lt;/span&gt;        &lt;span class="na"&gt;send_resolved&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;heartbeat&lt;/span&gt;
    &lt;span class="na"&gt;webhook_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://example.com/hooks/heartbeat"&lt;/span&gt;     &lt;span class="c1"&gt;# an external heartbeat monitor
&lt;/span&gt;        &lt;span class="na"&gt;send_resolved&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The root route has no matchers, so it catches everything that isn't a page or a heartbeat, and those become tickets. Alertmanager recommends &lt;code&gt;repeat_interval&lt;/code&gt; be a multiple of &lt;code&gt;group_interval&lt;/code&gt;, which all of mine are. I use webhooks to keep the example short. Alertmanager also has built-in receivers for email, Slack, PagerDuty, and others.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5: One dashboard
&lt;/h2&gt;

&lt;p&gt;I build a single "golden signals" dashboard in Grafana. Alerts wake me up, and the dashboard is where I find out what's wrong.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Panel&lt;/th&gt;
&lt;th&gt;PromQL&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Traffic (requests per second)&lt;/td&gt;
&lt;td&gt;sum(rate(http_request_duration_seconds_count[5m]))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error ratio&lt;/td&gt;
&lt;td&gt;sum(rate(http_request_duration_seconds_count{status=~"5.."}[5m])) / sum(rate(http_request_duration_seconds_count[5m]))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency p95&lt;/td&gt;
&lt;td&gt;histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error ratio by version&lt;/td&gt;
&lt;td&gt;sum by (version) (rate(http_request_duration_seconds_count{status=~"5.."}[5m])) / sum by (version) (rate(http_request_duration_seconds_count[5m]))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency p95 by version&lt;/td&gt;
&lt;td&gt;histogram_quantile(0.95, sum by (le, version) (rate(http_request_duration_seconds_bucket[5m])))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Five slowest routes&lt;/td&gt;
&lt;td&gt;topk(5, histogram_quantile(0.95, sum by (le, route) (rate(http_request_duration_seconds_bucket[5m]))))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU used&lt;/td&gt;
&lt;td&gt;1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory available&lt;/td&gt;
&lt;td&gt;node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database connections used&lt;/td&gt;
&lt;td&gt;sum by (instance) (pg_stat_activity_count) / max by (instance) (pg_settings_max_connections)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Event loop lag&lt;/td&gt;
&lt;td&gt;nodejs_eventloop_lag_seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The two "by version" panels show what a deploy changed. If the error ratio steps up exactly when a new version appears, I know where to look. Grafana can also draw deploy markers, and the pipeline can create one per deploy through Grafana's HTTP API.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 6: Make every deploy watch itself
&lt;/h2&gt;

&lt;p&gt;My smoke test checks that the new version is &lt;em&gt;serving&lt;/em&gt;. This step checks that it's serving &lt;em&gt;well&lt;/em&gt;: it watches that version's real traffic for a few minutes and fails if the error ratio or latency is bad.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# /srv/zyvop/verify-release.sh &amp;lt;sha&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;# Watch the new version's real traffic for a few minutes. Exit 1 if it looks unhealthy.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="nv"&gt;PROM&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${PROM_URL:-http://localhost:9090}"&lt;/span&gt;
&lt;span class="nv"&gt;VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${1:0:7}"&lt;/span&gt;                       &lt;span class="c"&gt;# the app labels its metrics with the 7-character SHA&lt;/span&gt;
&lt;span class="nv"&gt;WATCH_SECONDS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${WATCH_SECONDS:-300}"&lt;/span&gt;
&lt;span class="nv"&gt;INTERVAL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${INTERVAL:-30}"&lt;/span&gt;
&lt;span class="nv"&gt;MIN_REQUESTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${MIN_REQUESTS:-20}"&lt;/span&gt;
&lt;span class="nv"&gt;MAX_ERROR_RATIO&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${MAX_ERROR_RATIO:-0.02}"&lt;/span&gt;
&lt;span class="nv"&gt;MAX_P95_SECONDS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"${MAX_P95_SECONDS:-1.0}"&lt;/span&gt;

&lt;span class="nv"&gt;SEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"version=\"$VERSION\""&lt;/span&gt;
&lt;span class="nv"&gt;REQUESTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sum(increase(http_request_duration_seconds_count{$SEL}[5m]))"&lt;/span&gt;
&lt;span class="nv"&gt;ERRORS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"(sum(rate(http_request_duration_seconds_count{$SEL,status=~\"5..\"}[5m])) or vector(0)) / sum(rate(http_request_duration_seconds_count{$SEL}[5m]))"&lt;/span&gt;
&lt;span class="nv"&gt;P95&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket{$SEL}[5m])))"&lt;/span&gt;

query&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;   &lt;span class="c"&gt;# first value of an instant query, or "none" when there is no data&lt;/span&gt;
  curl -fsS --max-time 10 --get &lt;span class="s2"&gt;"$PROM/api/v1/query"&lt;/span&gt; --data-urlencode &lt;span class="s2"&gt;"query=$1"&lt;/span&gt; \
    &lt;span class="o"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;'.data.result[0].value[1] // "none"'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
is_number&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$1"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;~ ^&lt;span class="o"&gt;[&lt;/span&gt;0-9&lt;span class="o"&gt;]&lt;/span&gt;+&lt;span class="o"&gt;(&lt;/span&gt;\.&lt;span class="o"&gt;[&lt;/span&gt;0-9&lt;span class="o"&gt;]&lt;/span&gt;+&lt;span class="o"&gt;)&lt;/span&gt;?&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;eE&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;-+&lt;span class="o"&gt;]&lt;/span&gt;?&lt;span class="o"&gt;[&lt;/span&gt;0-9&lt;span class="o"&gt;]&lt;/span&gt;+&lt;span class="o"&gt;)&lt;/span&gt;?$ &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
greater&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;   &lt;span class="o"&gt;{&lt;/span&gt; is_number &lt;span class="s2"&gt;"$1"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; awk -v &lt;span class="nv"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$1"&lt;/span&gt; -v &lt;span class="nv"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$2"&lt;/span&gt; &lt;span class="s1"&gt;'BEGIN { exit !(a &amp;gt; b) }'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
at_least&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;{&lt;/span&gt; is_number &lt;span class="s2"&gt;"$1"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; awk -v &lt;span class="nv"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$1"&lt;/span&gt; -v &lt;span class="nv"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$2"&lt;/span&gt; &lt;span class="s1"&gt;'BEGIN { exit !(a &amp;gt;= b) }'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;deadline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;date +%s&lt;span class="o"&gt;)&lt;/span&gt; + WATCH_SECONDS &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;bad&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;span class="nv"&gt;judged&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;date +%s&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; deadline &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;query &lt;span class="s2"&gt;"$REQUESTS"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; at_least &lt;span class="s2"&gt;"$n"&lt;/span&gt; &lt;span class="s2"&gt;"$MIN_REQUESTS"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nv"&gt;judged&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
    &lt;span class="nv"&gt;err&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;query &lt;span class="s2"&gt;"$ERRORS"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nv"&gt;p95&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;query &lt;span class="s2"&gt;"$P95"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; greater &lt;span class="s2"&gt;"$err"&lt;/span&gt; &lt;span class="s2"&gt;"$MAX_ERROR_RATIO"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; greater &lt;span class="s2"&gt;"$p95"&lt;/span&gt; &lt;span class="s2"&gt;"$MAX_P95_SECONDS"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
      &lt;span class="nv"&gt;bad&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;bad + 1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"unhealthy ($bad in a row): error ratio $err, p95 ${p95}s"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; bad &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; 2 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"version $VERSION failed verification"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
        &lt;span class="nb"&gt;exit&lt;/span&gt; 1
      &lt;span class="k"&gt;fi&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
      &lt;span class="nv"&gt;bad&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0
      &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"healthy: $n requests, error ratio $err, p95 ${p95}s"&lt;/span&gt;
    &lt;span class="k"&gt;fi&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"not enough traffic yet for $VERSION (requests in the last 5m: $n)"&lt;/span&gt;
  &lt;span class="k"&gt;fi&lt;/span&gt;
  sleep &lt;span class="s2"&gt;"$INTERVAL"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; bad &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 0 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"version $VERSION was still unhealthy at the end of the window"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
  &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; judged &lt;span class="o"&gt;==&lt;/span&gt; 0 &lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"warning: $VERSION never reached $MIN_REQUESTS requests, so nothing was judged"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"verification finished for $VERSION"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How it behaves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It judges only with enough traffic.&lt;/strong&gt; Below &lt;code&gt;MIN_REQUESTS&lt;/code&gt; in the last five minutes, a single failed request would look like a 50% error rate, so it waits instead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It needs two bad checks in a row.&lt;/strong&gt; One blip doesn't fail a deploy, but a problem that persists for a minute does.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No 5xx series at all counts as zero errors.&lt;/strong&gt; The &lt;code&gt;or vector(0)&lt;/code&gt; handles that, because the numerator would otherwise be empty and the whole ratio would return nothing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A version that never gets enough traffic is not blamed.&lt;/strong&gt; It prints a warning and passes, because the smoke test already confirmed it's serving.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;If Prometheus is unreachable, the script fails.&lt;/strong&gt; I'd rather a deploy complain that it can't see the metrics than claim a healthy result it didn't check.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It needs&lt;/strong&gt; &lt;code&gt;jq&lt;/code&gt; &lt;strong&gt;on the deploy host&lt;/strong&gt;, and &lt;code&gt;PROM_URL&lt;/code&gt; pointing at Prometheus if it isn't running locally.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The version comes from the pipeline's entry script, which already requires exactly 40 lowercase hex characters, so nothing unsafe reaches the query. I add one branch to the &lt;code&gt;case&lt;/code&gt; in &lt;code&gt;ci-entry.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;verify&lt;span class="o"&gt;)&lt;/span&gt;
    valid_sha &lt;span class="s2"&gt;"$version"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"invalid version"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;2&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 2&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="nb"&gt;exec&lt;/span&gt; /srv/zyvop/verify-release.sh &lt;span class="s2"&gt;"$version"&lt;/span&gt;
    &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And one step at the end of the deploy job in &lt;code&gt;deploy.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Watch the new version's real traffic&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ssh -o BatchMode=yes -o ServerAliveInterval=30 deploy@"$DEPLOY_HOST" "verify $SHA"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ServerAliveInterval&lt;/code&gt; keeps the SSH connection from being dropped while the script waits. The job's 30-minute timeout leaves plenty of room for the five-minute watch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNptkcFu2zAMQH-F01kGWmw9zAcD2dzGOwwIaizYIRdFpmMisqhJdFavyL8PclK0WKcbxUc-UnpWljtUpUr4a0JvsSZziGbceQCAYKKQpWC8wLoBk2BN0kx7WFkh9uk9VS9UjcHxDAMneY9sMrGJPKIMOKWdvyDrpqiquikhpQG6S4O2WV2SdVMUVbVuSnhk58gfXoiOPb6pz0Q78hFBMAnYAe0xwc9iFUKxxZiI_2c7YaT-jc0xB8ATxhk-3kBCy75L0HOEOxjJT4LXza-jVdWmhPsYOUI0QgzGdxA-3y0lMlDKhld3Ppvi6t8aN720Q9_9u-79EwncAPUwoHEyzBpuc-RZlFYjxtFQp8pnJQOO-R877M3kcnK52ZpIZu8wZaZnLw9mJDerUhUmBIdFmpPgqOGLI3_8bmy7xA_sRcNOtXhghB_fdkrDI-9ZWEOD7oRC1mhYRTJOQzI-FSk_otKLpKU_eZbbT-FJnc9a7Q9f2XFUpfrweyBBdf4LWmXL-Q%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNptkcFu2zAMQH-F01kGWmw9zAcD2dzGOwwIaizYIRdFpmMisqhJdFavyL8PclK0WKcbxUc-UnpWljtUpUr4a0JvsSZziGbceQCAYKKQpWC8wLoBk2BN0kx7WFkh9uk9VS9UjcHxDAMneY9sMrGJPKIMOKWdvyDrpqiquikhpQG6S4O2WV2SdVMUVbVuSnhk58gfXoiOPb6pz0Q78hFBMAnYAe0xwc9iFUKxxZiI_2c7YaT-jc0xB8ATxhk-3kBCy75L0HOEOxjJT4LXza-jVdWmhPsYOUI0QgzGdxA-3y0lMlDKhld3Ppvi6t8aN720Q9_9u-79EwncAPUwoHEyzBpuc-RZlFYjxtFQp8pnJQOO-R877M3kcnK52ZpIZu8wZaZnLw9mJDerUhUmBIdFmpPgqOGLI3_8bmy7xA_sRcNOtXhghB_fdkrDI-9ZWEOD7oRC1mhYRTJOQzI-FSk_otKLpKU_eZbbT-FJnc9a7Q9f2XFUpfrweyBBdf4LWmXL-Q%3Ftype%3Dpng" alt="Mermaid Diagram" width="805" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this step fails, the job goes red and I get notified. Then I decide whether to run the rollback workflow. I don't roll back automatically yet. An automatic rollback has to be built so it can't loop or fight with a human, and I'd rather earn that trust first.&lt;/p&gt;




&lt;h2&gt;
  
  
  Who watches the watcher?
&lt;/h2&gt;

&lt;p&gt;If Prometheus or Alertmanager dies, silence looks exactly like "everything is fine." Two cheap defenses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The&lt;/strong&gt; &lt;code&gt;Watchdog&lt;/code&gt; &lt;strong&gt;alert&lt;/strong&gt; always fires. Alertmanager sends it to an external heartbeat service every few minutes, and that service alerts me when the heartbeats &lt;em&gt;stop&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;An external uptime check&lt;/strong&gt; from a provider outside my infrastructure. It only knows whether the site answers, which is exactly why it keeps working when everything I run myself is down.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Mistakes I'm trying not to make
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Paging on causes.&lt;/strong&gt; CPU at 85% isn't an emergency. Visitors getting errors is.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Paging on everything.&lt;/strong&gt; After a week of false alarms, I'll start ignoring the real one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using averages.&lt;/strong&gt; They hide the slow tail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;High-cardinality labels.&lt;/strong&gt; Raw URLs, user IDs, and emails will overwhelm Prometheus.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Exposing&lt;/strong&gt; &lt;code&gt;/metrics&lt;/code&gt;&lt;strong&gt;, Prometheus, or Grafana to the internet.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Copying thresholds without a baseline.&lt;/strong&gt; What's normal for someone else isn't normal for zyvop.com.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Never testing the alert path.&lt;/strong&gt; I send a test alert through each receiver before I need one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No heartbeat.&lt;/strong&gt; A dead monitoring system doesn't alert.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  My monitoring checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The app exports a request histogram labelled by route pattern, status, and short version&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;/metrics&lt;/code&gt; is on an internal port, firewalled, with the right &lt;code&gt;Content-Type&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;node_exporter&lt;/code&gt; on every server, plus Postgres and Redis exporters&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;External HTTPS probe, ideally from outside my own network&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pages only for &lt;code&gt;SiteDown&lt;/code&gt;, &lt;code&gt;HighErrorRate&lt;/code&gt;, and &lt;code&gt;HighLatency&lt;/code&gt;. Everything else is a ticket&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every alert has a &lt;code&gt;for:&lt;/code&gt; duration and a summary I'll understand at 3 a.m.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redis memory alert has its &lt;code&gt;maxmemory &amp;gt; 0&lt;/code&gt; guard&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Alertmanager routes pages, tickets, and the heartbeat separately&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prometheus, Alertmanager, and Grafana are private, on their own server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One golden-signals dashboard, including by-version panels&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The deploy pipeline runs the post-deploy verification&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A heartbeat and an external uptime check cover the monitoring itself&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I've sent a test alert through every receiver&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Good monitoring is mostly restraint: a small set of signals, a short list of alerts that deserve to interrupt me, and one dashboard I actually understand. The part I like most is the by-version labelling, because it turns "did that deploy break something?" from a hunch into a graph.&lt;/p&gt;

&lt;p&gt;Next in the series is hardening the path that deploys all of this: the SSH keys, firewall rules, and secrets the pipeline depends on.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What's the best alert you've ever had, and the worst false alarm? Tell me in the comments and I'll cover it in a follow-up.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/what-i-monitor-on-zyvop-com-and-the-alerts-worth-waking-up-for-17wfz?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>alerting</category>
      <category>devops</category>
      <category>grafana</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>How to Hand Claude a Long Task and Walk Away</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Thu, 26 Nov 2026 03:05:20 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/how-to-hand-claude-a-long-task-and-walk-away-4m13</link>
      <guid>https://dev.to/sanjay_singh_1/how-to-hand-claude-a-long-task-and-walk-away-4m13</guid>
      <description>&lt;p&gt;You give Claude a big job and go make coffee. You come back to a tidy summary that ends with "Next, I'll tackle the remaining sections." Then nothing.&lt;/p&gt;

&lt;p&gt;Anthropic's prompting guide for Claude Opus 5.5 describes exactly this: on long, multi-part tasks the model keeps you updated as it works, and some of those updates end the turn instead of continuing. Anthropic also says Opus 5.5 carries long, multipart work through to the end better than Opus 5 did. Better isn't automatic, though, so the handoff still matters.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The guide's fixes for early stopping are written for developers who build agent loops. I've translated them into things you can type. Which Claude apps can run unattended for long stretches depends on the product and your plan.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The handoff at a glance
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNpVkkGP00AMhf-Kca8TCVhAKAfQtt3ASsBhqwWhzh7cjNMZdRpHM05DqfrfUVKpuxzHet-znz0nrMUxlthEGWpPSeHbg20BAG7XFn-loAzqGTYpcFPCVigaaEIbsmcH0mvXq4HBcwsqQHln8QmK4hPM1xYXkXrHsOlDdBkIas_1LoasFp8uTeaTdvGsHSTtMqhP0m89BIUhqIfsJSlkJe0ztKKcrw6LyWF5sviD2WU4Sp-Aui7JgSJIAgLHdchB2s8WzxdoCUUBR84Te7e2eD-6S5eBWjemePa_u0z4gmtlKlVri9X_i4Au9mPOxDV1IA0MnnQM4YK7GlYT_WVt8bf0kPgQeJja5k60mFZ01daRcl5yA1sRB02IsZy5pnnPNyZrkh2Xs7f00dQSJZWz1x9uXmBQTRQa3HPaU3BYnlA978dzO26oj4rmUvlJKdAmch41jbRa0T7EI5ZYUNdFLvIxK-8NzGNod9-pXk3vSlo1YHHFW2F4vLdo4EE2omLgK8cDa6jJwG0K46_J1OYicwoNmqnJKvwdZ3nzrvuD57PBzXYxBsESXw0-KOP5H6j52gE%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNpVkkGP00AMhf-Kca8TCVhAKAfQtt3ASsBhqwWhzh7cjNMZdRpHM05DqfrfUVKpuxzHet-znz0nrMUxlthEGWpPSeHbg20BAG7XFn-loAzqGTYpcFPCVigaaEIbsmcH0mvXq4HBcwsqQHln8QmK4hPM1xYXkXrHsOlDdBkIas_1LoasFp8uTeaTdvGsHSTtMqhP0m89BIUhqIfsJSlkJe0ztKKcrw6LyWF5sviD2WU4Sp-Aui7JgSJIAgLHdchB2s8WzxdoCUUBR84Te7e2eD-6S5eBWjemePa_u0z4gmtlKlVri9X_i4Au9mPOxDV1IA0MnnQM4YK7GlYT_WVt8bf0kPgQeJja5k60mFZ01daRcl5yA1sRB02IsZy5pnnPNyZrkh2Xs7f00dQSJZWz1x9uXmBQTRQa3HPaU3BYnlA978dzO26oj4rmUvlJKdAmch41jbRa0T7EI5ZYUNdFLvIxK-8NzGNod9-pXk3vSlo1YHHFW2F4vLdo4EE2omLgK8cDa6jJwG0K46_J1OYicwoNmqnJKvwdZ3nzrvuD57PBzXYxBsESXw0-KOP5H6j52gE%3Ftype%3Dpng" alt="Mermaid Diagram" width="1251" height="249"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Write a brief, not a command
&lt;/h2&gt;

&lt;p&gt;Anthropic's advice for long work is to stop feeding Claude instructions one at a time. In your first message, describe three things:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;What to write&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Goal&lt;/td&gt;
&lt;td&gt;What you're trying to achieve, and why&lt;/td&gt;
&lt;td&gt;"Find out why store sales slowed this year so I can brief my manager."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Finished output&lt;/td&gt;
&lt;td&gt;Exactly what you want back, and in what form&lt;/td&gt;
&lt;td&gt;"A two-page memo and a spreadsheet of the numbers behind it."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;When to stop and ask&lt;/td&gt;
&lt;td&gt;The decisions that are yours&lt;/td&gt;
&lt;td&gt;"Ask before contacting anyone or deleting anything. Otherwise keep going."&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In Anthropic's own demo, the prompt simply described the problem and the result wanted, and trusted Claude to work out how to get there. It didn't point Claude to specific files. Another tip from the same article: skip the outline stage and ask for the finished spreadsheet or document directly.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Ask for a checklist
&lt;/h2&gt;

&lt;p&gt;For long jobs with several parts, the guide's advice to developers is to keep the parts in a checklist the model updates, and to nudge it by name if it stops with items still open. You can do both in chat. (The guide suggests a to-do tool or a file; in a plain chat window the list simply lives in Claude's replies.)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Start by listing the parts of this job as a checklist. Tick items off as you go, and don't finish while any are open unless something is blocking you."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If it stops early anyway, name what's left instead of just saying "continue":&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Items 4 and 5 are still open. Please carry on with them, and if something is blocking you, tell me what."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One adaptation of mine: the guide tells developers to stop after two or three automatic nudges so a genuinely stuck run ends and gets reviewed. If Claude still hasn't moved after two nudges, stop pushing and read what it says is in the way.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Name the early stops you don't want
&lt;/h2&gt;

&lt;p&gt;Anthropic says Opus 5.5 responds well to instructions that name the specific kinds of early stop to avoid. These are the four the guide describes, with wording you can use:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Early stop&lt;/th&gt;
&lt;th&gt;What it looks like&lt;/th&gt;
&lt;th&gt;What to tell Claude&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Announce and stop&lt;/td&gt;
&lt;td&gt;A detailed progress report that ends with "next I'll..." and then nothing happens&lt;/td&gt;
&lt;td&gt;"Do the next step in the same message instead of announcing it."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wait for a yes&lt;/td&gt;
&lt;td&gt;It offers to keep going, then sits idle until you reply&lt;/td&gt;
&lt;td&gt;"Don't ask permission to continue. Assume yes unless the step is on my approval list."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Decision dump&lt;/td&gt;
&lt;td&gt;It hands you open questions that don't actually hold up the remaining work&lt;/td&gt;
&lt;td&gt;"Pick the most sensible option, note it, and carry on with everything else."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Report by habit&lt;/td&gt;
&lt;td&gt;It decides this is a convenient place to check in, just because it has worked a while or finished a stage&lt;/td&gt;
&lt;td&gt;"Don't stop to report unless you are blocked."&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Just as important, say which stops you do want: when nothing can move without your input, or when what's blocking it is something deliberately kept out of its reach.&lt;/p&gt;

&lt;p&gt;One caveat from the guide: this kind of keep-going instruction is meant for work where no one is around to answer. If you'll be sitting there anyway, let Claude check in, and expect somewhat more work (and usage) per task when it doesn't.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Decide what needs your approval
&lt;/h2&gt;

&lt;p&gt;Rules that push Claude to keep going don't replace an approval list. Anthropic's guidance keeps confirmation in place for risky or destructive actions. Here is a starting split (my suggestion, so adjust it to your comfort level):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fine to let run&lt;/th&gt;
&lt;th&gt;Check with me first&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Reading files, emails, and records&lt;/td&gt;
&lt;td&gt;Sending or posting anything to other people&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Searching and researching&lt;/td&gt;
&lt;td&gt;Deleting or overwriting files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Analyzing and drafting&lt;/td&gt;
&lt;td&gt;Spending money or placing orders&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Building a document, spreadsheet, or deck&lt;/td&gt;
&lt;td&gt;Changing shared or live records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Making assumptions and noting them&lt;/td&gt;
&lt;td&gt;Sharing files outside your team&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  5. Tell it where to look
&lt;/h2&gt;

&lt;p&gt;If Claude is connected to your files and apps, the information a task depends on is often somewhere you didn't mention: a pricing exception in last quarter's email thread, a footnote on a different sheet. Opus 5.5 likes to start right away, so add one sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Before you begin, search my email, documents, and spreadsheets for anything related to this job, even things I haven't pointed you to."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In Anthropic's tests on multi-app tasks, a similar instruction made noticeably more of them finish correctly, at the cost of slightly more steps. Two cautions: on Team and Enterprise plans an owner has to turn a connector on before members can use it, and because Claude acts on what it finds, keep untrusted content out of the places you point it at.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. When it stops anyway
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNplkstu20AMRX-FnWxlIHaSLrRo4SQNGhR9JO4LsLKgJUoiNBqqw7EVxfC_FyM1cIosh-A995KcvcmlIJOa0kqf1-gDfL_OHADAap2ZK4vbgkCDdB0VmXmA2ewd3M33mflVY4CCC-CgYFEDtKSKFYHi8D4zh4lyN4fZDDLzhR4D3ELP1kIh8DuBUJMDJ6FmV0GNXUcuWowOy_k6M_fU2QE2AzhsY0-oCaQjBxyo1cw8_O-whD9b0sDiQJwdYJAt5OgAnfbkn8GLdWaWYwU4_AuhOEBD1EEl7KrXYG2ifUe-ZdXIL8WDSktTds_aDM_8szH4jqk_8rHrvOwIxIOngj3l4ZXJhx35YeKxQsmOtT6u4zzeoqa8AQ6AFbLTEAf0kMeqZT0Sl_PpSIt9ZlbT4SYJYBnIQ-gF3LaoSF9caRFTOBmVXz-tM3OJeQNBoBffHMOObQPplOpinZlvXja4sQNo2OZNCp6wgD7-DQ5xsRrH2VjJxx3yMWZuUfWaSujROyjZ2vSkLGhBi0SDl4bSk-LsLMnFik9P3p6evpDB8mKUmcS05FvkwqR7E2pq41cuqMStDSaZKj_RM24saewpxYUbbNkOJjUz7DpLMx00UJvApWXXfMZ8Nb5vxIUEMrOiSgh-3GYmgXvZSJAEPpLdUeAcE1h6RpuAotOZkufSJKPJip9ilvl592gOh8Rsqqs4iUnNm77mQObwF3IFIUg%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNplkstu20AMRX-FnWxlIHaSLrRo4SQNGhR9JO4LsLKgJUoiNBqqw7EVxfC_FyM1cIosh-A995KcvcmlIJOa0kqf1-gDfL_OHADAap2ZK4vbgkCDdB0VmXmA2ewd3M33mflVY4CCC-CgYFEDtKSKFYHi8D4zh4lyN4fZDDLzhR4D3ELP1kIh8DuBUJMDJ6FmV0GNXUcuWowOy_k6M_fU2QE2AzhsY0-oCaQjBxyo1cw8_O-whD9b0sDiQJwdYJAt5OgAnfbkn8GLdWaWYwU4_AuhOEBD1EEl7KrXYG2ifUe-ZdXIL8WDSktTds_aDM_8szH4jqk_8rHrvOwIxIOngj3l4ZXJhx35YeKxQsmOtT6u4zzeoqa8AQ6AFbLTEAf0kMeqZT0Sl_PpSIt9ZlbT4SYJYBnIQ-gF3LaoSF9caRFTOBmVXz-tM3OJeQNBoBffHMOObQPplOpinZlvXja4sQNo2OZNCp6wgD7-DQ5xsRrH2VjJxx3yMWZuUfWaSujROyjZ2vSkLGhBi0SDl4bSk-LsLMnFik9P3p6evpDB8mKUmcS05FvkwqR7E2pq41cuqMStDSaZKj_RM24saewpxYUbbNkOJjUz7DpLMx00UJvApWXXfMZ8Nb5vxIUEMrOiSgh-3GYmgXvZSJAEPpLdUeAcE1h6RpuAotOZkufSJKPJip9ilvl592gOh8Rsqqs4iUnNm77mQObwF3IFIUg%3Ftype%3Dpng" alt="Mermaid Diagram" width="893" height="921"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  7. When you come back
&lt;/h2&gt;

&lt;p&gt;Anthropic says Opus 5.5 reports back clearly on long tasks, spelling out the work done, the findings, and any help it needs from you. That makes the work easier to check, but check it anyway:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;How&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Is every checklist item done or explained?&lt;/td&gt;
&lt;td&gt;Ask for the list again, with a status next to each item&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What did it assume?&lt;/td&gt;
&lt;td&gt;Ask what it assumed or guessed along the way&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What was left out?&lt;/td&gt;
&lt;td&gt;Ask what it couldn't finish or couldn't access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Do the numbers and quotes trace to sources?&lt;/td&gt;
&lt;td&gt;Spot-check a few against the originals. Anthropic calls Opus 5.5 careful with figures and sources, but in one of its tests 16 of 18 research reports passed a strict check for invented figures and quotes, so not every one did&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  A note on limits and effort
&lt;/h2&gt;

&lt;p&gt;Opus 5.5 is the default model on Pro, Max, Ultra, and Team plans, and Anthropic notes that higher-priced models use your plan limits faster. For a well-scoped job with a clear brief, Anthropic says Sonnet 5.5 is faster and cheaper, though at higher effort levels its cost per task gets close to Opus 5.5's. If the result falls short of what you expected, try a higher effort level before moving up a model. To change it, click the model name next to the send button and choose Effort.&lt;/p&gt;




&lt;h2&gt;
  
  
  The handoff template
&lt;/h2&gt;

&lt;p&gt;Copy, fill in the brackets, and paste:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal: [what I'm trying to achieve, and why it matters]
Finished output: [exactly what I want back, and in what format]
Where to look: Before you begin, search [folders, emails, docs, tabs] for anything related to this job, even things I haven't pointed you to.

How to work: List the parts of this job as a checklist and tick them off as you go.
Keep going until every item is done. Put short status notes in the same message
as your next step instead of stopping to report.

Stop and ask me only if nothing can move without my answer, or before you
[send, delete, share, buy, or change anything shared]. Otherwise make a
reasonable assumption, carry on, and note it.

When you finish: tell me what you did, what you assumed, and anything you
could not complete.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pattern running through all of it: &lt;strong&gt;say what done looks like, say when to ask, and let Claude do the rest.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Anthropic, &lt;a href="https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5-5" rel="noopener noreferrer"&gt;Prompting Claude Opus 5.5&lt;/a&gt; (unattended runs, progress updates, multi-app workflows)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anthropic, &lt;a href="https://claude.com/resources/articles/using-claude-opus-5-5-as-your-daily-driver-for-knowledge-work" rel="noopener noreferrer"&gt;Using Claude Opus 5.5 as your daily driver for knowledge work&lt;/a&gt; (November 12, 2026: the three-part brief, effort, plan limits, connectors)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example prompts and the approval split are my own wording and suggestions.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/how-to-hand-claude-a-long-task-and-walk-away-f6ita?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aiagents</category>
      <category>aidelegation</category>
      <category>claudeopus55</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Renaming a Database Column Without Downtime</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Wed, 25 Nov 2026 04:25:34 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/renaming-a-database-column-without-downtime-3366</link>
      <guid>https://dev.to/sanjay_singh_1/renaming-a-database-column-without-downtime-3366</guid>
      <description>&lt;p&gt;My earlier &lt;a href="https://zyvop.com/setting-up-ci-cd-for-zyvop-com-with-github-actions-test-build-tag-deploy-roll-back-r8vrp" rel="noopener noreferrer"&gt;posts&lt;/a&gt; kept saying "expand and contract" without ever showing it end to end. This one does. I'll rename &lt;code&gt;users.fullname&lt;/code&gt; to &lt;code&gt;users.display_name&lt;/code&gt; on a live PostgreSQL database, one safe step at a time. The sequence works on any database, but the SQL and locking details below are PostgreSQL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; never rename in one step. Add the new column, dual-write, backfill in batches, verify, switch reads, stop writing the old column, and only then drop it. Put a &lt;code&gt;lock_timeout&lt;/code&gt; on every DDL statement.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why a plain rename breaks
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="no"&gt;RENAME&lt;/span&gt; &lt;span class="k"&gt;COLUMN&lt;/span&gt; &lt;span class="n"&gt;fullname&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="n"&gt;display_name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It runs instantly, and it still causes an outage, for three reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Running code breaks immediately.&lt;/strong&gt; During a rolling deploy, old and new versions run side by side. Anything still saying &lt;code&gt;fullname&lt;/code&gt; (old servers, workers, cron jobs, scripts) starts failing the moment the rename lands.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It needs an&lt;/strong&gt; &lt;code&gt;ACCESS EXCLUSIVE&lt;/code&gt; &lt;strong&gt;lock&lt;/strong&gt;, which conflicts with everything, including plain &lt;code&gt;SELECT&lt;/code&gt;. If a long query is holding the table, the &lt;code&gt;ALTER&lt;/code&gt; waits, and every query that arrives after it queues behind it. A "fast" statement can stall the whole table.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rolling back the code doesn't un-rename the column.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Many ORMs' rename helpers just run that one statement, so I don't use them on a live table.&lt;/p&gt;




&lt;h2&gt;
  
  
  The plan
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNpVkWFP2zAQhv_KcZ-dbAzYpGpjIi0IJOBDqhVNMZou8aW1cOzIdhe6qv99ioMq-OhXz-P3fN5j4xTjDFvjhmZDPsJ9KS0AwHUl8TSH69eerPpe-0-XpBQoHXpDuz-WOpb4DFl2CYtK4pccFlsy2eB15ER7NkyB4Uri83TjItFFJfEsh4Kal1Ybk1hnFHg3BAHaQk2x2XA4akXSVnuJ5zms2Ot2l6ROh25C4Qd8_inxMPEryDJ4dFPZu-g3h5SVlcSLHEomBZaHD8MWx9YysU-VxK85LKPrYXyatmtwRn1w5kfnKTnzSuK3HObORk9NTKzyrod2a8zb3lBgx74jrXC2x7jhbvwExS1tTUQxJSvymmrDYWRaZ-MNddrscIYZ9b3hLOxC5E5AYbR9eaBmmc43zkYBEpe8dgy_7iQKKF3tohNwy-YvR92QgCuvyQgIZEMWxq2iSCVL_W-c5fS8f8XDQWC9njvjPM7wZNjoyHj4D4BDsWE%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNpVkWFP2zAQhv_KcZ-dbAzYpGpjIi0IJOBDqhVNMZou8aW1cOzIdhe6qv99ioMq-OhXz-P3fN5j4xTjDFvjhmZDPsJ9KS0AwHUl8TSH69eerPpe-0-XpBQoHXpDuz-WOpb4DFl2CYtK4pccFlsy2eB15ER7NkyB4Uri83TjItFFJfEsh4Kal1Ybk1hnFHg3BAHaQk2x2XA4akXSVnuJ5zms2Ot2l6ROh25C4Qd8_inxMPEryDJ4dFPZu-g3h5SVlcSLHEomBZaHD8MWx9YysU-VxK85LKPrYXyatmtwRn1w5kfnKTnzSuK3HObORk9NTKzyrod2a8zb3lBgx74jrXC2x7jhbvwExS1tTUQxJSvymmrDYWRaZ-MNddrscIYZ9b3hLOxC5E5AYbR9eaBmmc43zkYBEpe8dgy_7iQKKF3tohNwy-YvR92QgCuvyQgIZEMWxq2iSCVL_W-c5fS8f8XDQWC9njvjPM7wZNjoyHj4D4BDsWE%3Ftype%3Dpng" alt="Mermaid Diagram" width="1481" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;What ships&lt;/th&gt;
&lt;th&gt;App writes&lt;/th&gt;
&lt;th&gt;App reads&lt;/th&gt;
&lt;th&gt;Roll back the app?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Expand&lt;/td&gt;
&lt;td&gt;Migration: add display_name&lt;/td&gt;
&lt;td&gt;fullname&lt;/td&gt;
&lt;td&gt;fullname&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Dual-write&lt;/td&gt;
&lt;td&gt;Release A&lt;/td&gt;
&lt;td&gt;both&lt;/td&gt;
&lt;td&gt;fullname&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Backfill&lt;/td&gt;
&lt;td&gt;Data migration, in batches&lt;/td&gt;
&lt;td&gt;both&lt;/td&gt;
&lt;td&gt;fullname&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Verify&lt;/td&gt;
&lt;td&gt;One query&lt;/td&gt;
&lt;td&gt;both&lt;/td&gt;
&lt;td&gt;fullname&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Read new&lt;/td&gt;
&lt;td&gt;Release B&lt;/td&gt;
&lt;td&gt;both&lt;/td&gt;
&lt;td&gt;display_name&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6. Stop writing old&lt;/td&gt;
&lt;td&gt;Release C&lt;/td&gt;
&lt;td&gt;display_name&lt;/td&gt;
&lt;td&gt;display_name&lt;/td&gt;
&lt;td&gt;To B yes, to A no (it would read a stale fullname)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7. Contract&lt;/td&gt;
&lt;td&gt;Migration: drop fullname&lt;/td&gt;
&lt;td&gt;display_name&lt;/td&gt;
&lt;td&gt;display_name&lt;/td&gt;
&lt;td&gt;No. Point of no return&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The rule:&lt;/strong&gt; ship each step only after the previous one is fully deployed everywhere, including background workers, cron jobs, and one-off scripts.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Expand
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;lock_timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'3s'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;ADD&lt;/span&gt; &lt;span class="k"&gt;COLUMN&lt;/span&gt; &lt;span class="n"&gt;display_name&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Adding a nullable column with no default doesn't rewrite the table.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;lock_timeout&lt;/code&gt; is the important line. If the lock isn't available within 3 seconds, the statement fails instead of joining the queue and blocking everyone behind it. I wait a few seconds and run it again.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If my migration tool wraps migrations in a transaction, I use &lt;code&gt;SET LOCAL lock_timeout&lt;/code&gt; so the setting doesn't leak.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This ships as its own migration step, before the app code that uses the column.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the old column has an index, create the equivalent on the new one now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="no"&gt;CONCURRENTLY&lt;/span&gt; &lt;span class="n"&gt;users_display_name_idx&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;display_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;CONCURRENTLY&lt;/code&gt; avoids blocking writes, but it can't run inside a transaction block, so my migration tool has to run it without one. If it fails partway, it leaves an &lt;code&gt;INVALID&lt;/code&gt; index behind. I drop that index and try again.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Dual-write (release A)
&lt;/h2&gt;

&lt;p&gt;Every write sets both columns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s2"&gt;"UPDATE users SET fullname = $1, display_name = $1 WHERE id = $2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inserts set both too. Reads still use &lt;code&gt;fullname&lt;/code&gt;. I route every write through one shared function so no code path is missed: app code, workers, admin scripts, import jobs. If I can't guarantee every writer is updated, a database trigger that keeps the two columns in sync is the safety net, but it's more moving parts, so I only use one when I have to.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Backfill
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;display_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fullname&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;
  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;display_name&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;fullname&lt;/span&gt; &lt;span class="k"&gt;IS&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;
  &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;
  &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A small script runs this repeatedly, with a short pause between batches, until it reports zero rows updated.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Batches matter.&lt;/strong&gt; One giant &lt;code&gt;UPDATE&lt;/code&gt; holds locks for a long time, bloats the table (every updated row becomes a new row version), and can make replicas lag.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;fullname IS NOT NULL&lt;/code&gt; &lt;strong&gt;is not optional.&lt;/strong&gt; A row whose &lt;code&gt;fullname&lt;/code&gt; is &lt;code&gt;NULL&lt;/code&gt; would match &lt;code&gt;display_name IS NULL&lt;/code&gt; forever, the update would never change it, and the loop would never finish.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It's safe alongside dual-write.&lt;/strong&gt; It only touches rows the app hasn't already filled.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 4: Verify
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) FROM users WHERE display_name IS DISTINCT FROM fullname;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This must return &lt;code&gt;0&lt;/code&gt;. &lt;code&gt;IS DISTINCT FROM&lt;/code&gt; treats &lt;code&gt;NULL&lt;/code&gt; as a comparable value, so two NULLs count as equal. A plain &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; would skip any row where either side is &lt;code&gt;NULL&lt;/code&gt; (because &lt;code&gt;NULL &amp;lt;&amp;gt; 'x'&lt;/code&gt; is &lt;code&gt;NULL&lt;/code&gt;, not true), so it would report zero mismatches even when rows are missing. The query scans the table, so I run it off-peak.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5: Read the new column (release B)
&lt;/h2&gt;

&lt;p&gt;Release B reads &lt;code&gt;display_name&lt;/code&gt; and keeps dual-writing. Every row now has a value and every writer keeps it current, so reads are correct. Because it still writes &lt;code&gt;fullname&lt;/code&gt;, rolling back to release A is safe.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 6: Stop writing the old column (release C)
&lt;/h2&gt;

&lt;p&gt;Release C writes only &lt;code&gt;display_name&lt;/code&gt;. From here, &lt;code&gt;fullname&lt;/code&gt; goes stale, which is why rolling back to A is no longer safe.&lt;/p&gt;

&lt;p&gt;I wait at least one full release cycle here. Before moving on, I search the codebase for &lt;code&gt;fullname&lt;/code&gt;, and check the database's query statistics (&lt;code&gt;pg_stat_statements&lt;/code&gt;, if enabled) for any query still touching it. Reports, dashboards, and exports are the usual stragglers.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 7: Contract
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;lock_timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'3s'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;COLUMN&lt;/span&gt; &lt;span class="n"&gt;fullname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It ships as a separate, later migration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's quick. PostgreSQL just makes the column invisible, and the disk space is reclaimed gradually.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The default is &lt;code&gt;RESTRICT&lt;/code&gt;, so it fails if a view or other object still depends on the column. I fix the dependency instead of reaching for &lt;code&gt;CASCADE&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's the point of no return. Code that still needs &lt;code&gt;fullname&lt;/code&gt; will break, and getting the data back means restoring a backup.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What else knows the old name
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Thing&lt;/th&gt;
&lt;th&gt;What I do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Indexes and unique constraints&lt;/td&gt;
&lt;td&gt;Create equivalents on the new column before step 5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NOT NULL&lt;/td&gt;
&lt;td&gt;Backfill first, then ADD CONSTRAINT ... CHECK (display_name IS NOT NULL) NOT VALID, then VALIDATE CONSTRAINT, then SET NOT NULL. PostgreSQL skips the full scan when a valid CHECK already proves there are no NULLs. I drop the CHECK in a separate statement afterwards. Each statement takes a brief lock, so lock_timeout applies to every one.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Views, functions, triggers&lt;/td&gt;
&lt;td&gt;Update them before the contract step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API responses and clients&lt;/td&gt;
&lt;td&gt;A column rename doesn't have to change an API field. I keep the API stable or version it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reports, ETL, BI dashboards&lt;/td&gt;
&lt;td&gt;Search for them and warn their owners&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Rehearsed the whole sequence on a copy of production data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;lock_timeout&lt;/code&gt; set on every DDL statement, with a retry plan&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expand migration ships before the code that uses the new column&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every writer dual-writes: app, workers, scripts, imports&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Backfill runs in batches with &lt;code&gt;fullname IS NOT NULL&lt;/code&gt;, until 0 rows updated&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verification query returns 0 using &lt;code&gt;IS DISTINCT FROM&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each step is fully deployed before the next one ships&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contract is a separate migration, after a quiet period&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Indexes, constraints, views, functions, API, and reports checked&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;The rename itself is one line of SQL. The safe version is seven small, boring steps, and that's the point: at every step, both the current release and the previous one work, so a deploy never needs the database to change at the same instant as the code.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you been bitten by a rename or migration on a live database? Tell me in the comments and I'll cover it in a follow-up.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/renaming-a-database-column-without-downtime-h9r5k?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>databasemigrations</category>
      <category>devops</category>
      <category>expandandcontract</category>
      <category>postgres</category>
    </item>
    <item>
      <title>WebRTC Calls Work on Wi-Fi but Fail on Mobile Networks? Set Up Your Own TURN Server with Coturn</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Sat, 21 Nov 2026 09:49:03 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/webrtc-calls-work-on-wi-fi-but-fail-on-mobile-networks-set-up-your-own-turn-server-with-coturn-5h9e</link>
      <guid>https://dev.to/sanjay_singh_1/webrtc-calls-work-on-wi-fi-but-fail-on-mobile-networks-set-up-your-own-turn-server-with-coturn-5h9e</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Stack:&lt;/strong&gt; Ubuntu 24.04, Coturn, Node.js, WebRTC, VPS&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A WebRTC application can work perfectly on a local Wi-Fi network and still fail when users connect from mobile networks or different internet providers.&lt;/p&gt;

&lt;p&gt;One possible cause is NAT traversal.&lt;/p&gt;

&lt;p&gt;A device behind a router or mobile carrier's NAT may not be reachable through the network path selected by WebRTC. STUN helps discover the public-facing address, but it cannot guarantee that two devices can establish a direct connection.&lt;/p&gt;

&lt;p&gt;TURN solves this by relaying traffic through a server that both clients can reach.&lt;/p&gt;

&lt;p&gt;Instead of depending entirely on a third-party TURN provider, you can run your own TURN server on a VPS using Coturn.&lt;/p&gt;

&lt;p&gt;This guide covers the server setup, authentication, firewall configuration, Node.js integration and testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understand the problem
&lt;/h2&gt;

&lt;p&gt;WebRTC uses ICE (Interactive Connectivity Establishment) to find a working network path between two peers.&lt;/p&gt;

&lt;p&gt;During connection establishment, ICE gathers different types of candidates:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Candidate&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Host&lt;/td&gt;
&lt;td&gt;Local network address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Server reflexive (srflx)&lt;/td&gt;
&lt;td&gt;Public-facing address discovered using STUN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relay&lt;/td&gt;
&lt;td&gt;Address allocated by a TURN server&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;STUN helps discover an address. TURN provides a relay when a direct connection cannot be established.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;User A connects through home Wi-Fi.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User B connects through a mobile network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Their NAT or firewall configurations prevent a direct connection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ICE cannot establish a usable direct candidate pair.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Both peers can use a TURN server as an alternative network path.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TURN forwards the traffic between the peers. It does not transcode the audio or video.&lt;/p&gt;

&lt;h3&gt;
  
  
  How ICE chooses a connection
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNp1kU1PwzAMhv-K8Tk9IHHqAbR1H-zADvsAoYaDl3o0WppUaWCUsf-O0o5NSHC09bx-X9sHVK5gTHFr3F6V5AOsRtICAAxyicsQO0-8WawyUM5aVkE7K_EFkuQWhrnEKYWSPcyyMSiyhS4ocCPxpR8y7Lgsl7h4sz10mvKuQwuqZLW70FlHjw4SM7JAUGjPKkBNoYS987s7iceeHEXyS-Jz9PqCcczKJsInzTkL1KT92eFHN3dRNsklrhuG1XoxB8-G2r92mHSppheLjuTiP49xx9_nEk-Hq7jQ9Pt8PTntSRRYsa9IF5geMJRcxY8UvKU3E1D0nUfymjaGm8hsnQ0TqrRpMcWE6tpw0rRN4ErA0Gi7eyC17OqJs0FAjP7qGNYziQIWbuOCE3DP5p2DViRg4DUZAQ3ZJmnY6y2KzmSpP2OW65v6A49HgZvXzBnnMcWrfakD4_EbwVq5ZA%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNp1kU1PwzAMhv-K8Tk9IHHqAbR1H-zADvsAoYaDl3o0WppUaWCUsf-O0o5NSHC09bx-X9sHVK5gTHFr3F6V5AOsRtICAAxyicsQO0-8WawyUM5aVkE7K_EFkuQWhrnEKYWSPcyyMSiyhS4ocCPxpR8y7Lgsl7h4sz10mvKuQwuqZLW70FlHjw4SM7JAUGjPKkBNoYS987s7iceeHEXyS-Jz9PqCcczKJsInzTkL1KT92eFHN3dRNsklrhuG1XoxB8-G2r92mHSppheLjuTiP49xx9_nEk-Hq7jQ9Pt8PTntSRRYsa9IF5geMJRcxY8UvKU3E1D0nUfymjaGm8hsnQ0TqrRpMcWE6tpw0rRN4ErA0Gi7eyC17OqJs0FAjP7qGNYziQIWbuOCE3DP5p2DViRg4DUZAQ3ZJmnY6y2KzmSpP2OW65v6A49HgZvXzBnnMcWrfakD4_EbwVq5ZA%3Ftype%3Dpng" alt="Mermaid Diagram" width="360" height="926"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is why having a working STUN server alone is not enough for reliable WebRTC connectivity.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Protocols" rel="noopener noreferrer"&gt;MDN — Introduction to WebRTC protocols&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What we are going to build
&lt;/h2&gt;

&lt;p&gt;We will use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An Ubuntu VPS with a public IPv4 address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Coturn as the TURN server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A domain such as &lt;code&gt;turn.example.com&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's Encrypt for the TLS certificate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Node.js to generate temporary TURN credentials.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Network architecture
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNqF0MFqwkAQBuBXmc55Qyn0FEQwtqJQixi1B7eHSZyYwc1u2Kxaq757SWp76KXHGb6ff5gz5m7DGGNh3DEvyQd4mWsLADBYa5wxexj0Mn_fH7uK4U2ikWh8_xbJj0g6MXWZGAbL4ej87lct1hqHLuy97dRqlkK9z4zkMJl16FYHvSjqXzQ-iec8wGT4DDWFsgsdS7ZABxJDmWGNF0j-pBbL-St4NnSC4KkoJG_V4nboPwoVVuwrkg3GZwwlV-1LNlzQ3gRU35sVeWnbm9YUzoYRVWJOGGNEdW04ak5N4EpBYsTuppSn3TxyNijQmPLWMSwnGhXMXeaCUzBmc-AgOSkYeCGjoCHbRA17KVB1Jal8trc8PNYfeL0qzLZDZ5zHGO-OpQTG6xcIWZGP%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNqF0MFqwkAQBuBXmc55Qyn0FEQwtqJQixi1B7eHSZyYwc1u2Kxaq757SWp76KXHGb6ff5gz5m7DGGNh3DEvyQd4mWsLADBYa5wxexj0Mn_fH7uK4U2ikWh8_xbJj0g6MXWZGAbL4ej87lct1hqHLuy97dRqlkK9z4zkMJl16FYHvSjqXzQ-iec8wGT4DDWFsgsdS7ZABxJDmWGNF0j-pBbL-St4NnSC4KkoJG_V4nboPwoVVuwrkg3GZwwlV-1LNlzQ3gRU35sVeWnbm9YUzoYRVWJOGGNEdW04ak5N4EpBYsTuppSn3TxyNijQmPLWMSwnGhXMXeaCUzBmc-AgOSkYeCGjoCHbRA17KVB1Jal8trc8PNYfeL0qzLZDZ5zHGO-OpQTG6xcIWZGP%3Ftype%3Dpng" alt="Mermaid Diagram" width="838" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a direct connection is available, WebRTC can use it. Otherwise, both peers can use the TURN server to relay traffic.&lt;/p&gt;

&lt;p&gt;The TURN server is separate from your application signaling server. Your application still needs signaling to exchange SDP offers, answers and ICE candidates.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Prepare the VPS
&lt;/h2&gt;

&lt;p&gt;For this example, use an Ubuntu 24.04 VPS.&lt;/p&gt;

&lt;p&gt;You need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A public IPv4 address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Root or sudo access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A domain or subdomain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Access to the VPS firewall.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create an A record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Type: A
Name: turn
Value: YOUR_VPS_PUBLIC_IP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify DNS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig +short turn.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should return your VPS public IP.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Install Coturn
&lt;/h2&gt;

&lt;p&gt;Connect to your VPS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh root@YOUR_VPS_IP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update the packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt update
sudo apt upgrade -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Coturn and Certbot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo apt install coturn certbot -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Ubuntu package installations, check whether Coturn is enabled in the package configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo nano /etc/default/coturn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="na"&gt;TURNSERVER_ENABLED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then enable and start the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; --now coturn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will configure Coturn next.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Generate a TURN authentication secret
&lt;/h2&gt;

&lt;p&gt;Do not run a public TURN server without authentication.&lt;/p&gt;

&lt;p&gt;An unauthenticated TURN server can be abused as an open relay, resulting in unexpected bandwidth costs and potential abuse.&lt;/p&gt;

&lt;p&gt;Coturn supports time-limited credentials through its TURN REST authentication mechanism.&lt;/p&gt;

&lt;p&gt;Generate a shared secret:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openssl rand -hex 32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the output securely.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TURN_SHARED_SECRET=replace_with_generated_secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will use this same secret in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The Coturn configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your Node.js backend environment.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Never expose this shared secret in frontend JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Obtain a TLS certificate
&lt;/h2&gt;

&lt;p&gt;Use Let's Encrypt to issue a certificate for your TURN domain.&lt;/p&gt;

&lt;p&gt;Make sure TCP port 80 is reachable from the internet and not occupied by another service when using the standalone challenge.&lt;/p&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo certbot certonly --standalone -d turn.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The certificate files will be available under:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/etc/letsencrypt/live/turn.example.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Coturn normally runs as an unprivileged system user. Verify its service account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl show coturn -p User -p Group
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the Ubuntu package used in this example, the account is &lt;code&gt;turnserver&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Copy the certificate and private key into a directory readable by that service account:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo install -d \
  -o root -g turnserver -m 750 \
  /etc/coturn/certs

sudo install \
  -o root -g turnserver -m 0640 \
  /etc/letsencrypt/live/turn.example.com/fullchain.pem \
  /etc/coturn/certs/fullchain.pem

sudo install \
  -o root -g turnserver -m 0640 \
  /etc/letsencrypt/live/turn.example.com/privkey.pem \
  /etc/coturn/certs/privkey.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your Coturn service runs under a different group, use that group instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep certificates working after renewal
&lt;/h3&gt;

&lt;p&gt;Let's Encrypt renews certificates by creating new files. A one-time copy is not enough.&lt;/p&gt;

&lt;p&gt;Create a deployment hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo nano /etc/letsencrypt/renewal-hooks/deploy/coturn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; -eu

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"${RENEWED_LINEAGE:-}"&lt;/span&gt; != \
  &lt;span class="s2"&gt;"/etc/letsencrypt/live/turn.example.com"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;span class="k"&gt;fi&lt;/span&gt;

install -o root -g turnserver -m 0640 \
  &lt;span class="s2"&gt;"$RENEWED_LINEAGE/fullchain.pem"&lt;/span&gt; \
  /etc/coturn/certs/fullchain.pem

install -o root -g turnserver -m 0640 \
  &lt;span class="s2"&gt;"$RENEWED_LINEAGE/privkey.pem"&lt;/span&gt; \
  /etc/coturn/certs/privkey.pem

systemctl restart coturn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make it executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo chmod 750 /etc/letsencrypt/renewal-hooks/deploy/coturn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;turn.example.com&lt;/code&gt; and the service group if necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Configure Coturn
&lt;/h2&gt;

&lt;p&gt;Open the configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo nano /etc/turnserver.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use this configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Listening ports
&lt;/span&gt;&lt;span class="na"&gt;listening-port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3478&lt;/span&gt;
&lt;span class="na"&gt;tls-listening-port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5349&lt;/span&gt;

&lt;span class="c1"&gt;# Authentication
&lt;/span&gt;&lt;span class="n"&gt;fingerprint&lt;/span&gt;
&lt;span class="n"&gt;use&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;
&lt;span class="na"&gt;static-auth-secret&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;YOUR_GENERATED_SECRET&lt;/span&gt;

&lt;span class="c1"&gt;# Domain
&lt;/span&gt;&lt;span class="na"&gt;realm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;turn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;

&lt;span class="c1"&gt;# Relay port range
&lt;/span&gt;&lt;span class="na"&gt;min-port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;49160&lt;/span&gt;
&lt;span class="na"&gt;max-port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;49999&lt;/span&gt;

&lt;span class="c1"&gt;# TLS certificates
&lt;/span&gt;&lt;span class="na"&gt;cert&lt;/span&gt;&lt;span class="o"&gt;=/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;coturn&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;certs&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;fullchain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pem&lt;/span&gt;
&lt;span class="na"&gt;pkey&lt;/span&gt;&lt;span class="o"&gt;=/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;coturn&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;certs&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;privkey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pem&lt;/span&gt;

&lt;span class="c1"&gt;# Basic peer restrictions
&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;loopback&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;peers&lt;/span&gt;
&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;multicast&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;peers&lt;/span&gt;

&lt;span class="c1"&gt;# Block private and non-public IPv4 destinations
&lt;/span&gt;&lt;span class="na"&gt;denied-peer-ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.255&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;255.255&lt;/span&gt;
&lt;span class="na"&gt;denied-peer-ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;10.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;10.255&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;255.255&lt;/span&gt;
&lt;span class="na"&gt;denied-peer-ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;100.64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;100.127&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;255.255&lt;/span&gt;
&lt;span class="na"&gt;denied-peer-ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;127.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;127.255&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;255.255&lt;/span&gt;
&lt;span class="na"&gt;denied-peer-ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;169.254&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;169.254&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;255.255&lt;/span&gt;
&lt;span class="na"&gt;denied-peer-ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;172.16&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;172.31&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;255.255&lt;/span&gt;
&lt;span class="na"&gt;denied-peer-ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;192.168&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;192.168&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;255.255&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;YOUR_GENERATED_SECRET&lt;/code&gt; with the secret generated earlier.&lt;/p&gt;

&lt;p&gt;The private-address restrictions help prevent TURN users from relaying traffic to internal services reachable from the VPS. Adjust them only when your application intentionally supports private peer destinations. Review IPv6 peer restrictions separately if your server supports IPv6.&lt;/p&gt;

&lt;p&gt;A few important configuration details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;3478&lt;/code&gt; accepts standard TURN connections over UDP and TCP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;5349&lt;/code&gt; accepts TURN over TLS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;49160-49999&lt;/code&gt; defines the relay port range.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;use-auth-secret&lt;/code&gt; enables Coturn's time-limited credential mechanism.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;static-auth-secret&lt;/code&gt; must match the secret in your backend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;cert&lt;/code&gt; and &lt;code&gt;pkey&lt;/code&gt; provide the TLS certificate and private key.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Coturn automatically enables its long-term credential mechanism internally when &lt;code&gt;use-auth-secret&lt;/code&gt; is enabled.&lt;/p&gt;

&lt;p&gt;The configuration uses standard Coturn options documented in its &lt;a href="https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf" rel="noopener noreferrer"&gt;official configuration&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Open the firewall ports
&lt;/h2&gt;

&lt;p&gt;TURN needs more than just port 3478.&lt;/p&gt;

&lt;p&gt;Open the required ports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ufw allow 3478/udp
sudo ufw allow 3478/tcp

sudo ufw allow 5349/tcp

sudo ufw allow 49160:49999/udp

sudo ufw allow 80/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep your actual SSH port allowed before enabling UFW.&lt;/p&gt;

&lt;p&gt;You must also open the same required ports in your VPS provider's firewall or security group.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Port&lt;/th&gt;
&lt;th&gt;Protocol&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3478&lt;/td&gt;
&lt;td&gt;UDP&lt;/td&gt;
&lt;td&gt;Standard TURN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3478&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;TURN over TCP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5349&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;TURN over TLS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;49160–49999&lt;/td&gt;
&lt;td&gt;UDP&lt;/td&gt;
&lt;td&gt;Media relay ports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;Certificate issuance and renewal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The relay range is important. Opening 3478 without opening the allocated relay ports can allow the initial TURN connection but still prevent media traffic from flowing.&lt;/p&gt;

&lt;p&gt;If your VPS provider maps its public IP to a private interface rather than assigning it directly to the network interface, configure Coturn's &lt;code&gt;external-ip&lt;/code&gt; option with the public/private address mapping. Do not add this setting blindly.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Restart Coturn
&lt;/h2&gt;

&lt;p&gt;Restart the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl restart coturn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable it at startup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; coturn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo systemctl status coturn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check listening sockets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo ss -lntup &lt;span class="o"&gt;|&lt;/span&gt; grep -E &lt;span class="s1"&gt;'3478|5349'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u coturn -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, the TURN server should be running.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Generate temporary TURN credentials using Node.js
&lt;/h2&gt;

&lt;p&gt;The backend must generate credentials using the shared secret.&lt;/p&gt;

&lt;p&gt;Coturn's REST authentication format is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;username = expiration_timestamp:user_id

password = Base64(
  HMAC-SHA1(shared_secret, username)
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The timestamp represents the credential's expiration time in Unix seconds.&lt;/p&gt;

&lt;p&gt;Here is an Express example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;createHmac&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:crypto"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/turn-credentials"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;requireAuth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;secret&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;TURN_SHARED_SECRET&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"TURN server is not configured"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Credentials expire after one hour.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;expiresAt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Use the authenticated user's ID, not an arbitrary&lt;/span&gt;
  &lt;span class="c1"&gt;// user ID supplied in the query string.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sb"&gt;`${expiresAt}:${req.user.id}`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;credential&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createHmac&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"sha1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"base64"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Cache-Control"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"no-store"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;iceServers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;urls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="s2"&gt;"turn:turn.example.com:3478?transport=udp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="s2"&gt;"turn:turn.example.com:3478?transport=tcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="s2"&gt;"turns:turn.example.com:5349?transport=tcp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;credential&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the backend environment variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TURN_SHARED_SECRET=YOUR_GENERATED_SECRET
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This must exactly match &lt;code&gt;static-auth-secret&lt;/code&gt; in &lt;code&gt;/etc/turnserver.conf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The endpoint should require authentication and use HTTPS. Never put the shared secret in the browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Connect the TURN server to WebRTC
&lt;/h2&gt;

&lt;p&gt;The frontend requests temporary credentials from your backend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/turn-credentials"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"include"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Could not obtain TURN credentials"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;iceServers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;peerConnection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RTCPeerConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;iceServers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all you need to add the TURN server to the ICE server configuration.&lt;/p&gt;

&lt;p&gt;You do not need to force relay mode for normal calls. ICE should try the available connection paths and select a working candidate pair.&lt;/p&gt;

&lt;p&gt;For diagnostics, however, you can force TURN:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;peerConnection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RTCPeerConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;iceServers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;iceTransportPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"relay"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prevents the connection from using host or server-reflexive candidates. It is useful for proving that your TURN server works, but it is generally not the setting to use for every production call because relaying all traffic increases latency and bandwidth consumption.&lt;/p&gt;

&lt;h3&gt;
  
  
  How credentials and TURN allocation work
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNqVk02P2jAQhv_K1GdTqVJPOayUsEXNYVGE2T1xGewJuPgjtR0oXfHfKxO2UNhtt8fJPH78zsh5ZtIrYgWL9L0nJ-le4yqgXTgAAOyTd71dUhjqDkPSUnfoEpSAERqiAOUrzabO7alX9PFbzOUtU_0WVLdNkZtCrxwa7VYgKGxfCzHP2NinPjh4asTCDUg5ursrm7qAWZ4qJpg_zqYgAylySaOJJ6ypR5ksYE628wHDHvpIwaElQKegwxh3PqgXb_Vf3urd3pxXFCDIKRD3Dfi2pXAk6_EXkOiUVpjopBeDe-LDDoO6gK_B6kqLLu7-4S3P3gv6kjwnnhfD_KUxXmIiCMNWBmJ-Wu2MDO7PhstVvkNQvSmY-kTgt_n98aoYBvLOkUx6q9Me5Jrk5jrvAymN0KHcUIov1_yxTXtLVH89W75xlnFmKVjUihXPLK3J5t9MUYu9SYwPX54waFwaiplpvUsTtNrsWcFG2HWGRnEfE1kOldFu84BSHOuJd4nDgglaeYLHesE4zPzSJ8_hK5ktJS2RQxk0Gg4RXRxFCrpl_HiJ0D9zlk-fux_scOBsuRp74wMr2IfdWidih19P0VW_%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNqVk02P2jAQhv_K1GdTqVJPOayUsEXNYVGE2T1xGewJuPgjtR0oXfHfKxO2UNhtt8fJPH78zsh5ZtIrYgWL9L0nJ-le4yqgXTgAAOyTd71dUhjqDkPSUnfoEpSAERqiAOUrzabO7alX9PFbzOUtU_0WVLdNkZtCrxwa7VYgKGxfCzHP2NinPjh4asTCDUg5ursrm7qAWZ4qJpg_zqYgAylySaOJJ6ypR5ksYE628wHDHvpIwaElQKegwxh3PqgXb_Vf3urd3pxXFCDIKRD3Dfi2pXAk6_EXkOiUVpjopBeDe-LDDoO6gK_B6kqLLu7-4S3P3gv6kjwnnhfD_KUxXmIiCMNWBmJ-Wu2MDO7PhstVvkNQvSmY-kTgt_n98aoYBvLOkUx6q9Me5Jrk5jrvAymN0KHcUIov1_yxTXtLVH89W75xlnFmKVjUihXPLK3J5t9MUYu9SYwPX54waFwaiplpvUsTtNrsWcFG2HWGRnEfE1kOldFu84BSHOuJd4nDgglaeYLHesE4zPzSJ8_hK5ktJS2RQxk0Gg4RXRxFCrpl_HiJ0D9zlk-fux_scOBsuRp74wMr2IfdWidih19P0VW_%3Ftype%3Dpng" alt="Mermaid Diagram" width="1356" height="994"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The signaling server shown here is your existing application infrastructure. Coturn does not exchange SDP offers or answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Test whether TURN is actually working
&lt;/h2&gt;

&lt;p&gt;Use the official WebRTC Trickle ICE test:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/" rel="noopener noreferrer"&gt;https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter your TURN server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TURN URI:
turn:turn.example.com:3478?transport=udp

Username:
Generated temporary username

Password:
Generated temporary credential
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the ICE transport policy to &lt;code&gt;relay&lt;/code&gt; and gather candidates.&lt;/p&gt;

&lt;p&gt;A successful TURN allocation should produce a candidate with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;typ relay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important distinction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;host&lt;/code&gt; means a local candidate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;srflx&lt;/code&gt; means a server-reflexive candidate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;relay&lt;/code&gt; means a TURN relay candidate.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you only see &lt;code&gt;host&lt;/code&gt; or &lt;code&gt;srflx&lt;/code&gt;, you have not established that TURN is working.&lt;/p&gt;

&lt;p&gt;Test the TLS endpoint separately using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;turns:turn.example.com:5349?transport=tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use valid temporary credentials for each test.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  No relay candidate appears
&lt;/h3&gt;

&lt;p&gt;Check that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;TCP/UDP port 3478 is open.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TCP port 5349 is open for TLS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;UDP relay ports 49160–49999 are open.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The VPS provider firewall allows the same traffic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DNS resolves to the correct IP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The certificate is valid.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The credentials are generated using the same secret configured in Coturn.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Authentication fails
&lt;/h3&gt;

&lt;p&gt;Check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo journalctl -u coturn -n 100 --no-pager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Different secrets in the backend and Coturn.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Incorrect HMAC input.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Incorrect username format.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An expired timestamp.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Incorrect server clock.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check time synchronization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;timedatectl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  TURN works on desktop but not on mobile
&lt;/h3&gt;

&lt;p&gt;Try the TCP and TLS TURN URLs.&lt;/p&gt;

&lt;p&gt;Some networks restrict UDP traffic. TURN over TCP or TLS gives the client an alternative transport to reach the TURN server.&lt;/p&gt;

&lt;p&gt;However, if the network blocks every available path to your TURN endpoint, the connection can still fail.&lt;/p&gt;

&lt;h3&gt;
  
  
  A relay candidate appears, but the call still fails
&lt;/h3&gt;

&lt;p&gt;A successful relay candidate proves that TURN allocation worked. It does not prove that the entire WebRTC call is healthy.&lt;/p&gt;

&lt;p&gt;Check the ICE candidate pair, signaling messages, SDP exchange, DTLS connection and browser logs.&lt;/p&gt;

&lt;p&gt;TURN cannot fix incorrect signaling or incompatible media negotiation.&lt;/p&gt;

&lt;h2&gt;
  
  
  14. Understand the bandwidth cost
&lt;/h2&gt;

&lt;p&gt;TURN relays media traffic. It is not just a signaling service.&lt;/p&gt;

&lt;p&gt;When a call uses a relay, the VPS processes and forwards media packets. The server's outbound bandwidth can therefore grow quickly with the number of calls, video quality and call duration.&lt;/p&gt;

&lt;p&gt;Before using a small VPS in production, monitor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Network ingress and egress.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Concurrent TURN allocations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CPU and memory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Failed allocations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bandwidth limits and provider overage charges.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Deploy the TURN server close to your users where possible. For a global application, one TURN server in one region may not provide acceptable latency everywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;If WebRTC works on Wi-Fi but fails on certain mobile or restricted networks, TURN should be part of your connectivity strategy.&lt;/p&gt;

&lt;p&gt;Coturn gives you control over the relay infrastructure, authentication and network configuration. A VPS with a public IP is enough to get started, provided the server has the required network access and bandwidth.&lt;/p&gt;

&lt;p&gt;The important part is not simply installing Coturn. It is configuring authenticated access, opening the relay port range, handling TLS certificates correctly, issuing temporary credentials and verifying that relay candidates are actually gathered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Official references&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Protocols" rel="noopener noreferrer"&gt;MDN: WebRTC protocols&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/coturn/coturn/wiki/turnserver" rel="noopener noreferrer"&gt;Coturn: TURN server documentation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf" rel="noopener noreferrer"&gt;Coturn: Configuration example&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/" rel="noopener noreferrer"&gt;WebRTC: Trickle ICE test&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/webrtc-calls-work-on-wi-fi-but-fail-on-mobile-networks-set-up-your-own-turn-server-with-coturn-7q7la?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>coturn</category>
      <category>networking</category>
      <category>turnserver</category>
      <category>vps</category>
    </item>
    <item>
      <title>Keep Old Article Links Working When You Move Your Blog</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Sat, 21 Nov 2026 03:39:02 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/keep-old-article-links-working-when-you-move-your-blog-31lj</link>
      <guid>https://dev.to/sanjay_singh_1/keep-old-article-links-working-when-you-move-your-blog-31lj</guid>
      <description>&lt;p&gt;When you move a blog, the articles may arrive safely while their old links stop working. Readers still have bookmarks, newsletters, social posts, and links from other sites that point to the previous URLs. A redirect gives those links a route to the article’s new home.&lt;/p&gt;

&lt;p&gt;The work starts before launch: decide which old URL corresponds to which new page, then make sure the redirect runs on the hostname that receives the old request. Here’s a practical way to plan that move with ZyVOP or another publishing setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make a map before changing URLs
&lt;/h2&gt;

&lt;p&gt;Export or collect the old article URLs while the old site is still available. Include the URL path, title, and the destination you plan to use. Add traffic or backlink information if you have it, so you can prioritize pages readers still visit.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Old path&lt;/th&gt;
&lt;th&gt;New destination&lt;/th&gt;
&lt;th&gt;Plan&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;/2022/09/cache-guide&lt;/td&gt;
&lt;td&gt;/cache-guide&lt;/td&gt;
&lt;td&gt;Redirect to the imported article&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;/engineering/queue-retries&lt;/td&gt;
&lt;td&gt;/distributed-retries&lt;/td&gt;
&lt;td&gt;Redirect to the renamed article&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;/tag/old-series&lt;/td&gt;
&lt;td&gt;/series/reliability&lt;/td&gt;
&lt;td&gt;Redirect only if the new page serves the same intent&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Prefer a direct, relevant destination for each article. Avoid sending every old URL to the new homepage: a reader who clicked a database guide expects that guide, not a generic landing page. Google’s site-move guidance also recommends mapping old URLs to their corresponding new URLs and avoiding irrelevant redirects. &lt;a href="https://developers.google.com/search/docs/crawling-indexing/site-move-with-url-changes" rel="noopener noreferrer"&gt;Google Search Central: Site moves with URL changes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If an old article has no equivalent and you are not keeping it, leave it unavailable or show a clear retired page instead of inventing an unrelated destination. Google recommends returning &lt;code&gt;404&lt;/code&gt; or &lt;code&gt;410&lt;/code&gt; for content that is not moving to the new site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decide where the redirect must run
&lt;/h2&gt;

&lt;p&gt;A redirect can only answer a request that reaches the server or platform handling that hostname. This makes the domain decision important:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keeping the same hostname:&lt;/strong&gt; If &lt;code&gt;blog.example.com&lt;/code&gt; will now point to the new publication, its path redirects can be handled there.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Changing hostnames:&lt;/strong&gt; If you move from &lt;code&gt;old.example.com&lt;/code&gt; to &lt;code&gt;new.example.com&lt;/code&gt;, keep the old hostname active and configure it to redirect requests to the matching pages on the new hostname. A redirect rule configured only on &lt;code&gt;new.example.com&lt;/code&gt; cannot receive a request sent to &lt;code&gt;old.example.com&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In ZyVOP, Publication URL redirects run on requests that reach an active custom publication domain. Custom-domain hosting and redirects require Founding Pro. ZyVOP’s separate article migration setting controls how ZyVOP network URLs behave; it does not automatically translate paths from an older CMS. If you change hostnames, arrange the old-host redirect with the service that still receives traffic for the old domain, such as the previous host or a domain proxy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose exact rules or a safe pattern
&lt;/h2&gt;

&lt;p&gt;Use an exact rule when an individual article’s new slug differs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/engineering/queue-retries → /distributed-retries
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A wildcard can save time when a whole section keeps the same path pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/old-guides/* → /guides/:splat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only use a pattern when it maps every matching path correctly. If old slugs were renamed inconsistently, create exact rules for those articles instead. ZyVOP supports exact paths, one wildcard, optional query matching, relative or HTTP(S) destinations, and status codes &lt;code&gt;301&lt;/code&gt;, &lt;code&gt;302&lt;/code&gt;, &lt;code&gt;307&lt;/code&gt;, and &lt;code&gt;308&lt;/code&gt;. A path-only rule preserves an incoming query string when its destination does not specify one. See &lt;a href="https://docs.zyvop.com/features/publication/domains-routing" rel="noopener noreferrer"&gt;ZyVOP Domains &amp;amp; Routing&lt;/a&gt; for the current behavior and limits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Select a status that matches the move
&lt;/h2&gt;

&lt;p&gt;For an article that has permanently moved, use a permanent server-side redirect. ZyVOP defaults custom path redirects to &lt;code&gt;301&lt;/code&gt;; it also supports &lt;code&gt;308&lt;/code&gt;. Use a temporary status such as &lt;code&gt;302&lt;/code&gt; or &lt;code&gt;307&lt;/code&gt; only when the change is genuinely temporary. Google Search Central recommends permanent HTTP redirects such as &lt;code&gt;301&lt;/code&gt; and &lt;code&gt;308&lt;/code&gt; for permanent URL changes, while noting that search visibility can fluctuate as a move is processed. &lt;a href="https://developers.google.com/search/docs/crawling-indexing/301-redirects" rel="noopener noreferrer"&gt;Google Search Central: Redirects and Google Search&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Avoid chains such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/old-article → /renamed-article → /new-section/renamed-article
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Point the old path straight to the final destination. This reduces extra requests and makes the redirect map easier to maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure and test the rules
&lt;/h2&gt;

&lt;p&gt;Once the new publication is live on its custom domain, open &lt;strong&gt;Publication → Domain &amp;amp; Routing → Redirects&lt;/strong&gt; and add the rules from your map. ZyVOP checks relative-path rules for circular chains, blocks reserved system paths, and lets you edit, disable, or remove rules later.&lt;/p&gt;

&lt;p&gt;Test representative URLs before sharing the new site:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open each important old link and confirm it reaches the intended article.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check the HTTP status and &lt;code&gt;Location&lt;/code&gt; header, not just the final page in a browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test wildcard examples at the beginning, middle, and end of the pattern’s expected range.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try links with query parameters if campaigns or readers depend on them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Confirm the destination loads directly and does not redirect again.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can inspect a response with &lt;code&gt;curl&lt;/code&gt;, replacing the example with an old URL you control:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -sS -D - -o /dev/null &lt;span class="s2"&gt;"https://blog.example.com/2022/09/cache-guide"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response should show the intended permanent status and destination. Also update internal links in navigation, series pages, and recent articles so your own site points directly to the new URLs. Update links you control elsewhere too, such as author profiles, newsletters, and social bios.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep redirects and canonical signals consistent
&lt;/h2&gt;

&lt;p&gt;Redirects and canonical URLs do different jobs. A redirect sends a visitor from one URL to another; a canonical declaration identifies the preferred URL when content is available at multiple locations. During a move, update the new article’s canonical URL, internal links, and sitemap so they agree with the destination you want readers to use. ZyVOP’s &lt;a href="https://docs.zyvop.com/features/canonical-links" rel="noopener noreferrer"&gt;canonical links guide&lt;/a&gt; explains how those signals work and their limits.&lt;/p&gt;

&lt;p&gt;After launch, check traffic and crawl errors for both the old and new URLs in your analytics and Search Console properties. If you moved to a different domain or subdomain, submit a Change of Address in Search Console for the old site. Keep the old hostname and its redirects working for as long as you can. Google recommends keeping redirects for at least a year during a site move; from a reader’s perspective, leaving them in place indefinitely is helpful when practical. Redirects can preserve a route to moved content, but they do not guarantee rankings or prevent temporary search changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  A clean move starts with a useful destination
&lt;/h2&gt;

&lt;p&gt;Import and review the articles first, choose a stable URL for each one, and build the redirect map before switching traffic. Then configure redirects where the old requests actually arrive, test the important paths, and update links you control.&lt;/p&gt;

&lt;p&gt;The result is a move readers can follow: old bookmarks still lead to relevant work, and new links point directly to the publication’s current URLs.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/keep-old-article-links-working-when-you-move-your-blog-i5u5j?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>blogmigration</category>
      <category>redirects</category>
      <category>technicalwriting</category>
      <category>zyvop</category>
    </item>
    <item>
      <title>Build a Branded Developer Publication Without Building a CMS</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Sat, 21 Nov 2026 03:38:43 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/build-a-branded-developer-publication-without-building-a-cms-2659</link>
      <guid>https://dev.to/sanjay_singh_1/build-a-branded-developer-publication-without-building-a-cms-2659</guid>
      <description>&lt;p&gt;A developer blog can start as a few articles on an author profile. As your writing grows, you may want a more distinct home: one with its own name, visual identity, navigation, and pages for readers who want to learn about the publication.&lt;/p&gt;

&lt;p&gt;Building that home from scratch means taking responsibility for more than the design. You also need to maintain article rendering, search, mobile navigation, and the systems behind publishing. ZyVOP’s Publication feature gives you configurable pieces for those common needs, so you can focus on the identity and reading experience instead of building a CMS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Know when a publication is useful
&lt;/h2&gt;

&lt;p&gt;Your author profile and your publication serve different purposes. A profile represents you as a writer, with your biography, social links, articles, and activity. A publication represents a blog, engineering team, or editorial brand, with its own name, logo, layout, navigation, and pages.&lt;/p&gt;

&lt;p&gt;You can publish articles and use an author profile on the ZyVOP network without creating a separate publication. An independent hosted publication with a custom hostname requires the Founding Pro plan and an active custom domain, so it makes sense when a distinct brand and site are worth maintaining.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose a layout that fits the writing
&lt;/h2&gt;

&lt;p&gt;In the Publication workspace, open &lt;strong&gt;Appearance&lt;/strong&gt; and preview the available homepage layouts with real articles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Classic&lt;/strong&gt; gives a lead article, chronological stream, and utility sidebar.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stacked&lt;/strong&gt; presents a straightforward chronological feed for long-form writing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bento Grid&lt;/strong&gt; combines a featured article with a responsive card grid and supporting panels.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three share the publication’s branding, navigation, search, and responsive article pages. Choose based on how readers should browse your archive, not just which empty demo looks most striking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Apply the publication’s identity
&lt;/h2&gt;

&lt;p&gt;Set the publication name and description, then add visual details that make it recognizable. ZyVOP supports separate light and dark logos, a favicon, and social links. You can inherit social links from your profile or set publication-specific ones.&lt;/p&gt;

&lt;p&gt;Publication settings are separate from your author identity. That lets a company engineering blog carry its own logo and social links while articles still show their authors, or lets an independent writer create a publication brand without replacing their profile.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give readers clear ways to explore
&lt;/h2&gt;

&lt;p&gt;Add navigation links for the destinations readers need, such as &lt;strong&gt;Articles&lt;/strong&gt;, &lt;strong&gt;About&lt;/strong&gt;, &lt;strong&gt;Projects&lt;/strong&gt;, or a recurring series. Create static pages for information that belongs outside individual posts, then add those pages to your navigation. Published pages also appear in the footer.&lt;/p&gt;

&lt;p&gt;Publications include full-text search across published articles. Readers can search from the header, while responsive navigation keeps the site usable on smaller screens. These parts are easy to overlook when building a site yourself, but they shape how readers move from one article to another.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect a custom hostname when you’re ready
&lt;/h2&gt;

&lt;p&gt;Once the publication’s identity and layout are ready, connect a root domain or subdomain in &lt;strong&gt;Publication → Domain &amp;amp; Routing&lt;/strong&gt;. ZyVOP provides the DNS records for verification and provisions TLS after the domain is verified. Custom-domain hosting and publication activation require Founding Pro.&lt;/p&gt;

&lt;p&gt;In the default &lt;strong&gt;Network Integrated&lt;/strong&gt; mode, articles render on the publication domain while their ZyVOP network URLs remain canonical. In &lt;strong&gt;Standalone&lt;/strong&gt; mode, the publication domain becomes canonical and network URLs permanently redirect there. Check the article migration settings before changing an established site.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review the reader journey
&lt;/h2&gt;

&lt;p&gt;Before sharing the publication, view it as a reader on both desktop and mobile. Check that the homepage explains what the publication covers, the logo works in light and dark themes, navigation labels make sense, and static pages are published. Open an article, try search, follow a series link, and, if newsletter signup is enabled, confirm it appears where you expect it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spend time on the publication, not the infrastructure
&lt;/h2&gt;

&lt;p&gt;A publication still needs a clear editorial purpose and thoughtful design. ZyVOP supplies the hosted layout and publishing features; you decide what the publication stands for, which articles belong there, and how readers should find them.&lt;/p&gt;

&lt;p&gt;If an author profile is enough, start there. When you need a separate brand and are ready for the plan and custom-domain requirements, use the Publication workspace to set the layout, identity, pages, and navigation—without having to build and maintain a CMS first.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/build-a-branded-developer-publication-without-building-a-cms-s151t?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>blogging</category>
      <category>developerpublication</category>
      <category>developertools</category>
      <category>zyvop</category>
    </item>
    <item>
      <title>Add Live Mermaid Diagrams to Your Technical Articles</title>
      <dc:creator>Sanjay Singh</dc:creator>
      <pubDate>Sat, 21 Nov 2026 03:37:46 +0000</pubDate>
      <link>https://dev.to/sanjay_singh_1/add-live-mermaid-diagrams-to-your-technical-articles-40im</link>
      <guid>https://dev.to/sanjay_singh_1/add-live-mermaid-diagrams-to-your-technical-articles-40im</guid>
      <description>&lt;p&gt;A paragraph can explain a request path. A diagram can show the whole path at once: where the request starts, which services handle it, and what happens when something fails.&lt;/p&gt;

&lt;p&gt;Mermaid lets you describe that diagram as text. Because the source stays in your article, you can revise a label or add a step without opening a separate drawing app or replacing an exported image. ZyVOP previews Mermaid blocks in the editor; on a published article page, the browser renders the block as an SVG diagram.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with a question a diagram can answer
&lt;/h2&gt;

&lt;p&gt;Before writing Mermaid syntax, decide what the reader needs to understand. A useful diagram usually answers one focused question:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;What happens after a request reaches the API?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Which steps run when a deployment fails?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How do services exchange events?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Which states can an order move through?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avoid trying to map an entire product in one diagram. Choose one flow or relationship, then use the surrounding article to explain decisions and exceptions.&lt;/p&gt;

&lt;p&gt;For example, an incident response guide could use a flowchart to show the first decisions an on-call engineer makes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNplkE9PG0EMxb-K8Xn2UKmnHIpoKtQc6IEAEmI4ODPeXYv5s5rxBmiS717tJgGhnizb7-f3ZnbosmdcYBvyq-upKNz9sgkA4Cpw0SeLc4XCjmXL3uIzNM0PWMWBnO4sLseqOXIBmSeXFg9H_qiYxPtHrnu4EZWOlJ8s3rIfHUMuUDUPJ9Li83_gn7yHVdpy_UCXPbsXCLmrQMnPsZKC6yl1XD9OnL3mqA8UxJ_onFopESqXrTiGnilo_-n8afWFPG7P3bxa5hjHJO78IJeLh1aSl3SKNg6zuCrpOCVDg5FLJPG42KH2HKd_99zSGBTNcfJARWgTuE6aNie9pijhHRfY0DAEbup7VY4GfgZJLzfk1nN_nZMasLjmLjPcrywauM2brNnAbw5bVnFk4KoIBQOVUm0qF2nRzCZr-Ttl-fZ9eMPDweCmW-aQCy7w4rUXZTz8A8QSu_I%3Ftype%3Dpng" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmermaid.ink%2Fimg%2Fpako%3AeNplkE9PG0EMxb-K8Xn2UKmnHIpoKtQc6IEAEmI4ODPeXYv5s5rxBmiS717tJgGhnizb7-f3ZnbosmdcYBvyq-upKNz9sgkA4Cpw0SeLc4XCjmXL3uIzNM0PWMWBnO4sLseqOXIBmSeXFg9H_qiYxPtHrnu4EZWOlJ8s3rIfHUMuUDUPJ9Li83_gn7yHVdpy_UCXPbsXCLmrQMnPsZKC6yl1XD9OnL3mqA8UxJ_onFopESqXrTiGnilo_-n8afWFPG7P3bxa5hjHJO78IJeLh1aSl3SKNg6zuCrpOCVDg5FLJPG42KH2HKd_99zSGBTNcfJARWgTuE6aNie9pijhHRfY0DAEbup7VY4GfgZJLzfk1nN_nZMasLjmLjPcrywauM2brNnAbw5bVnFk4KoIBQOVUm0qF2nRzCZr-Ttl-fZ9eMPDweCmW-aQCy7w4rUXZTz8A8QSu_I%3Ftype%3Dpng" alt="Mermaid Diagram" width="360" height="651"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The diagram makes the shared validation step visible: after mitigation, confirm recovery; when no impact is found, confirm the alert source and service state. The prose can then explain what “customer impact” means in your system, who owns mitigation, and which signals count as recovery.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add the diagram to your article
&lt;/h2&gt;

&lt;p&gt;In a Markdown document, put the Mermaid definition in a fenced code block labeled &lt;code&gt;mermaid&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;

![Mermaid Diagram](https://mermaid.ink/img/pako:eNolzkFrg0AQBeC_Mp3z7KHQk4eCaQkVUgiRthcvo45xya4ju5vYNPjfi3qb9_HgzQMbbQUz7JxOTc8hweFUDQAAu6BTlADGvEJ-LDbMj8UKPxouEjbb7pXfOXHNUZDQS_BsW8wemHrxy0YrHV9dQtrkm4Pl2klcOp0Oac_eujtmaHgcnZh4j0k8wc7Z4fLJTbnmvQ6JoMJSzirwVVRIcNJakxJ8iLtJsg0T5MGyI4g8RBMl2A5pHSnt3_LL88v4i_NMWJ_f1GnADJ-m3ibB-R_t-1pf?type=png)



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the ZyVOP editor, set the code block language to &lt;strong&gt;Mermaid&lt;/strong&gt;. The block offers &lt;strong&gt;Code&lt;/strong&gt;, &lt;strong&gt;Split&lt;/strong&gt;, and &lt;strong&gt;Preview&lt;/strong&gt; views, so you can edit the source and check the rendered result without leaving the article. Use the article preview too, especially when the diagram is wide or includes long labels.&lt;/p&gt;

&lt;p&gt;The source remains ordinary text in your Markdown. That makes changes easy to review in Git, and it gives you a straightforward way to keep the diagram close to the explanation it supports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the visual easy to scan
&lt;/h2&gt;

&lt;p&gt;Diagrams work best when their structure is simpler than the system they describe. A few habits help:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use labels readers recognize.&lt;/strong&gt; Prefer the service or action name used in the article over internal abbreviations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Show only relevant branches.&lt;/strong&gt; If a path is unusual, explain it in prose or give it a separate diagram.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keep direction consistent.&lt;/strong&gt; Use top-to-bottom for a sequence of steps and left-to-right for a pipeline or comparison.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Break up long labels.&lt;/strong&gt; Short node text is easier to read on a phone and less likely to make the diagram too wide.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Introduce and summarize the diagram.&lt;/strong&gt; Tell readers what to look for, then describe any implication that is not obvious from the arrows.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That last step matters for accessibility as well as clarity. A diagram should reinforce the explanation, not carry information that appears nowhere else in the article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the source and the rendered result
&lt;/h2&gt;

&lt;p&gt;Mermaid syntax is compact, but a missing arrow or malformed node can prevent a diagram from rendering. Preview after meaningful edits. Confirm that each branch leads somewhere sensible, labels match the surrounding text, and the result remains readable at a narrow screen width.&lt;/p&gt;

&lt;p&gt;Also check whether the diagram reflects the current system. When an API changes or a service is removed, update the diagram in the same review as the code or documentation change. A text-based diagram is easier to maintain, but it can still become stale if nobody owns it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Know what happens when you cross-post
&lt;/h2&gt;

&lt;p&gt;ZyVOP renders Mermaid diagrams from their source in ZyVOP articles. For Dev.to, Hashnode, Medium, and WordPress cross-posts, ZyVOP replaces Mermaid blocks with PNG image references generated through mermaid.ink. Those copies show a static image rather than a live diagram and do not include the editable Mermaid source.&lt;/p&gt;

&lt;p&gt;If a diagram is essential to a cross-post, review how it looks on that destination after delivery. Keep the explanation in the article text too, so the article still makes sense if a destination handles the image differently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the diagram part of the explanation
&lt;/h2&gt;

&lt;p&gt;A diagram is useful when it reduces the effort required to understand a system. Start with one reader question, draw only the path that answers it, and use the article to explain the context the picture cannot show.&lt;/p&gt;

&lt;p&gt;With Mermaid in ZyVOP, the diagram source and the technical article can evolve together. Write the flow as text, preview the rendered visual, and keep both in step with the system you are documenting.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Published via &lt;a href="https://zyvop.com/add-live-mermaid-diagrams-to-your-technical-articles-wwoho?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=syndication" rel="noopener noreferrer"&gt;ZyVOP&lt;/a&gt; — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium &amp;amp; Hashnode in 1 click.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>developertools</category>
      <category>mermaid</category>
      <category>technicalwriting</category>
      <category>zyvop</category>
    </item>
  </channel>
</rss>
