<?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: hoagminh</title>
    <description>The latest articles on DEV Community by hoagminh (@hoagminh).</description>
    <link>https://dev.to/hoagminh</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%2F4229201%2F85d96d43-d789-44be-90b9-e294d957a6d2.jpg</url>
      <title>DEV Community: hoagminh</title>
      <link>https://dev.to/hoagminh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hoagminh"/>
    <language>en</language>
    <item>
      <title>The Hidden Docker Compose DNS Trap Behind Shared Traefik Networks</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Fri, 27 Nov 2026 10:26:37 +0000</pubDate>
      <link>https://dev.to/hoagminh/the-hidden-docker-compose-dns-trap-behind-shared-traefik-networks-2k7o</link>
      <guid>https://dev.to/hoagminh/the-hidden-docker-compose-dns-trap-behind-shared-traefik-networks-2k7o</guid>
      <description>&lt;p&gt;Almost every self-hosting tutorial for Traefik and Docker Compose shows the same pattern: create one external &lt;code&gt;proxy&lt;/code&gt; network, then add it to every app's &lt;code&gt;docker-compose.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="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;kong&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;kong:2.8&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;default&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;proxy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works cleanly for your first app. It even looks fine for your second app—until two separate apps on the same VPS happen to share a Compose service name like &lt;code&gt;kong&lt;/code&gt;, &lt;code&gt;web&lt;/code&gt;, &lt;code&gt;api&lt;/code&gt;, &lt;code&gt;app&lt;/code&gt;, or &lt;code&gt;db&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;What most people miss is that &lt;strong&gt;Docker Compose registers the short service name as a DNS alias on &lt;em&gt;every&lt;/em&gt; network declared in that Compose file&lt;/strong&gt;—not just the app's private &lt;code&gt;default&lt;/code&gt; network, but the shared &lt;code&gt;proxy&lt;/code&gt; network too.&lt;/p&gt;

&lt;p&gt;If App A and App B both have a service named &lt;code&gt;kong&lt;/code&gt; attached to &lt;code&gt;proxy&lt;/code&gt; through &lt;code&gt;docker-compose.yml&lt;/code&gt;, Docker's embedded DNS maps &lt;code&gt;kong&lt;/code&gt; on &lt;code&gt;proxy&lt;/code&gt; to &lt;em&gt;both&lt;/em&gt; containers. When App A's internal dashboard resolves &lt;code&gt;http://kong:8000&lt;/code&gt;, it can land on &lt;strong&gt;App B's container&lt;/strong&gt; and send App A's &lt;code&gt;service_role&lt;/code&gt; key straight to the wrong app's gateway.&lt;/p&gt;

&lt;p&gt;We hit this exact class of cross-app DNS collision while building &lt;strong&gt;Nitrobase&lt;/strong&gt;—and solving it meant changing how shared networks are attached across every container lifecycle command.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. This pattern is not full Kubernetes network policy or L7 service mesh isolation. Its goal is narrower and practical for a single VPS: make sure containers sharing a reverse-proxy or database-link network can never accidentally resolve another app's service name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why &lt;code&gt;docker network connect&lt;/code&gt; behaves differently from Compose
&lt;/h2&gt;

&lt;p&gt;Traefik, Nitrobase's health probe, and database links never need bare service names like &lt;code&gt;kong&lt;/code&gt; or &lt;code&gt;web&lt;/code&gt; on a shared network—they address containers by their unique &lt;strong&gt;container name&lt;/strong&gt; (for example, &lt;code&gt;myapp-kong&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Unlike &lt;code&gt;docker compose&lt;/code&gt;, running plain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker network connect &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;shared-network&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;container-name&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;without &lt;code&gt;--alias&lt;/code&gt; registers &lt;strong&gt;only&lt;/strong&gt; the container's own unique name and short container ID on that network. No bare service name (&lt;code&gt;kong&lt;/code&gt;, &lt;code&gt;db&lt;/code&gt;, &lt;code&gt;web&lt;/code&gt;) is ever registered on the shared bridge.&lt;/p&gt;

&lt;p&gt;So Nitrobase's rule is strict: &lt;strong&gt;generated &lt;code&gt;docker-compose.yml&lt;/code&gt; files never declare the shared proxy network or database link networks.&lt;/strong&gt; Instead, Nitrobase writes a small sidecar file in the app folder (&lt;code&gt;.nitrobase-networks&lt;/code&gt;, one &lt;code&gt;&amp;lt;container&amp;gt;\t&amp;lt;network&amp;gt;&lt;/code&gt; pair per line, blocked from being bind-mounted into any container).&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoiding the startup race with &lt;code&gt;up --no-start&lt;/code&gt; -&amp;gt; &lt;code&gt;attach&lt;/code&gt; -&amp;gt; &lt;code&gt;up&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The obvious naive fix is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run &lt;code&gt;docker compose up -d&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;docker network connect&lt;/code&gt; afterward&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That creates an immediate startup race. A container that needs its database link network at boot—or needs to be reachable by Traefik from second zero—starts &lt;em&gt;before&lt;/em&gt; &lt;code&gt;docker network connect&lt;/code&gt; has run.&lt;/p&gt;

&lt;p&gt;Instead, every &lt;code&gt;compose up&lt;/code&gt; in Nitrobase (&lt;code&gt;composeLifecycleCommand&lt;/code&gt;) runs in three steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. docker compose up --no-start [--force-recreate ...]
        |   Creates/recreates containers without booting them yet
        |   (strips start-only flags: -d, --detach, --wait)
        v
2. attachNetworksScript (.nitrobase-networks)
        |   Verifies container name starts with "&amp;lt;folder&amp;gt;-"
        |   AND label nitrobase.app == &amp;lt;appId&amp;gt; (blocks name squatting)
        |   Skips already-attached pairs -&amp;gt; docker network connect &amp;lt;net&amp;gt; &amp;lt;container&amp;gt;
        v
3. docker compose up -d [without --force-recreate]
            Boots every container ALREADY attached to its shared networks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice two subtle safeguards in that flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--force-recreate&lt;/code&gt; is stripped before Step 3.&lt;/strong&gt; If you passed &lt;code&gt;--force-recreate&lt;/code&gt; to both phases, Step 3 would immediately recreate the containers a second time—wiping out the network attachments you just applied in Step 2!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ownership verification before attaching.&lt;/strong&gt; Before running &lt;code&gt;docker network connect&lt;/code&gt;, the script checks that the container name starts with the app's &lt;code&gt;&amp;lt;folder&amp;gt;-&lt;/code&gt; prefix &lt;em&gt;and&lt;/em&gt; that its &lt;code&gt;nitrobase.app&lt;/code&gt; Docker label matches the expected app ID. Another container squatting a predicted name causes the attach step to fail instead of silently joining the wrong network.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;restart&lt;/code&gt;, Nitrobase attaches &lt;em&gt;before&lt;/em&gt; starting (stopped containers retain their network attachments). For &lt;code&gt;create&lt;/code&gt;, it attaches right after.&lt;/p&gt;

&lt;h2&gt;
  
  
  Detecting and self-healing foreign Compose aliases
&lt;/h2&gt;

&lt;p&gt;What if an app was deployed before this rule existed, or someone manually ran &lt;code&gt;docker compose up&lt;/code&gt; with a shared network declared in the YAML?&lt;/p&gt;

&lt;p&gt;Nitrobase's background monitoring inspects only containers owned by the current panel instance (&lt;code&gt;nitrobase.instance=&amp;lt;id&amp;gt;&lt;/code&gt; and &lt;code&gt;nitrobase.app&lt;/code&gt;) and reads each container's aliases on the proxy network. Any alias other than the container's own name and short hex ID is classified as a &lt;strong&gt;foreign alias&lt;/strong&gt; (&lt;code&gt;foreignAliases&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;planNetworkRepairs&lt;/code&gt; then handles two self-healing cases:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition detected&lt;/th&gt;
&lt;th&gt;Repair action&lt;/th&gt;
&lt;th&gt;What it runs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Container is on the proxy network with foreign Compose aliases (&lt;code&gt;kong&lt;/code&gt;, &lt;code&gt;&amp;lt;project&amp;gt;-&amp;lt;service&amp;gt;-1&lt;/code&gt;, etc.)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;realias&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;docker network disconnect&lt;/code&gt; followed immediately by &lt;code&gt;docker network connect&lt;/code&gt; (sub-second reconnect that strips all foreign aliases)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routed container (&lt;code&gt;nitrobase.routed=true&lt;/code&gt;) is missing from the proxy network&lt;/td&gt;
&lt;td&gt;&lt;code&gt;attach&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;docker network connect&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To prevent an infinite disconnect/reconnect loop if something outside Nitrobase keeps re-attaching a container with Compose aliases, &lt;code&gt;guardNetworkRepairs&lt;/code&gt; adds a &lt;strong&gt;flap guard&lt;/strong&gt;: if the same container requires the same repair for more than &lt;code&gt;maxAttempts&lt;/code&gt; consecutive monitoring ticks, Nitrobase stops reconnecting it every tick and raises a &lt;code&gt;network_flap&lt;/code&gt; alert instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  A bonus Docker &lt;code&gt;inspect&lt;/code&gt; gotcha we hit along the way
&lt;/h2&gt;

&lt;p&gt;While building the network inspector, we hit a surprisingly subtle Docker CLI quirk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{.ID}}   &amp;lt;-- Go struct field name (stays on typed inspect result)
{{.Id}}   &amp;lt;-- JSON key name (fails typed lookup -&amp;gt; Docker falls back to raw JSON!)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a &lt;code&gt;docker inspect --format&lt;/code&gt; template uses &lt;code&gt;.Id&lt;/code&gt; instead of &lt;code&gt;.ID&lt;/code&gt;, Docker fails to evaluate the Go struct template and silently falls back to evaluating the template against the raw JSON map. On containers &lt;em&gt;without&lt;/em&gt; a healthcheck, the raw JSON omits &lt;code&gt;State.Health&lt;/code&gt; completely—causing &lt;code&gt;{{if .State.Health}}&lt;/code&gt; to error and silently drop that container from the entire inspect output. Sticking strictly to Go struct field names (&lt;code&gt;.ID&lt;/code&gt;, &lt;code&gt;.Name&lt;/code&gt;, &lt;code&gt;.NetworkSettings.Networks&lt;/code&gt;) keeps evaluation on the typed struct path and avoids missing rows.&lt;/p&gt;

&lt;h2&gt;
  
  
  What removing Compose aliases still does not isolate
&lt;/h2&gt;

&lt;p&gt;Removing shared service-name aliases prevents accidental cross-app DNS collisions and hostname hijacking across apps on the same proxy network. It does &lt;strong&gt;not&lt;/strong&gt; block raw IP-to-IP TCP traffic between two containers that are both attached to the same bridge network—if App A is compromised and actively scans the bridge subnet, it can still reach another container's port on that bridge unless you enforce L3 firewall/network isolation or separate hosts.&lt;/p&gt;

&lt;h2&gt;
  
  
  My checklist for multi-app Traefik + Docker Compose hosts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Never declare a shared &lt;code&gt;proxy&lt;/code&gt; network inside per-app &lt;code&gt;docker-compose.yml&lt;/code&gt; files when multiple apps can share service names (&lt;code&gt;web&lt;/code&gt;, &lt;code&gt;api&lt;/code&gt;, &lt;code&gt;app&lt;/code&gt;, &lt;code&gt;kong&lt;/code&gt;, &lt;code&gt;db&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;[ ] Attach only the routed containers via &lt;code&gt;docker network connect&lt;/code&gt; (no &lt;code&gt;--alias&lt;/code&gt;) so only unique container names resolve on the shared network&lt;/li&gt;
&lt;li&gt;[ ] Use &lt;code&gt;up --no-start&lt;/code&gt; -&amp;gt; &lt;code&gt;attach&lt;/code&gt; -&amp;gt; &lt;code&gt;up&lt;/code&gt; (with &lt;code&gt;--force-recreate&lt;/code&gt; only in phase 1) so containers boot with their networks already connected&lt;/li&gt;
&lt;li&gt;[ ] Inspect existing containers on your shared proxy network (&lt;code&gt;docker inspect --format '{{.Name}} -&amp;gt; {{with index .NetworkSettings.Networks "proxy"}}{{join .Aliases ","}}{{end}}'&lt;/code&gt;) to see which short service names are colliding right now&lt;/li&gt;
&lt;li&gt;[ ] Add a flap guard if you run automated network repairs so external drift raises an alert instead of looping forever&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Shared Docker networks feel harmless until two stacks share the word &lt;code&gt;api&lt;/code&gt; or &lt;code&gt;kong&lt;/code&gt;. Attaching containers outside Compose takes a few extra lines of lifecycle logic and eliminates an entire class of silent cross-app leaks.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>traefik</category>
      <category>security</category>
      <category>selfhosted</category>
    </item>
    <item>
      <title>Why docker compose up -d Returning 0 Does Not Mean Your App Is Ready</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Thu, 26 Nov 2026 12:25:44 +0000</pubDate>
      <link>https://dev.to/hoagminh/why-docker-compose-up-d-returning-0-does-not-mean-your-app-is-ready-4lcf</link>
      <guid>https://dev.to/hoagminh/why-docker-compose-up-d-returning-0-does-not-mean-your-app-is-ready-4lcf</guid>
      <description>&lt;p&gt;Almost every VPS deployment script ends the same way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Docker exits with code &lt;code&gt;0&lt;/code&gt;. Your CI pipeline turns green. Thirty seconds later, your monitoring alerts fire because the API container is stuck in a crash loop.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker compose up -d&lt;/code&gt; only tells you that Docker &lt;em&gt;started&lt;/em&gt; the containers. Even adding a single &lt;code&gt;docker inspect&lt;/code&gt; check right afterward still lies—a crash-looping container alternates between &lt;code&gt;restarting&lt;/code&gt; and &lt;code&gt;running&lt;/code&gt;, so a poll that happens to land during the one second it is &lt;code&gt;running&lt;/code&gt; reports a false success.&lt;/p&gt;

&lt;p&gt;This is the problem behind &lt;strong&gt;deploy readiness and OOM diagnostics&lt;/strong&gt; in Nitrobase.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. Its readiness tracker is not a full APM or distributed tracing suite. Its job is narrower: watch a multi-container Compose stack over time so a deploy only turns green when every service actually stays up—and when it fails, tell you &lt;em&gt;why&lt;/em&gt; instead of leaving you staring at a generic timeout.&lt;/p&gt;

&lt;h2&gt;
  
  
  One sample is never enough: require a stable window
&lt;/h2&gt;

&lt;p&gt;When Nitrobase runs &lt;code&gt;waitUntilHealthy&lt;/code&gt;, it polls &lt;code&gt;docker inspect&lt;/code&gt; every &lt;code&gt;5s&lt;/code&gt; (&lt;code&gt;APP_HEALTH_INTERVAL_MS&lt;/code&gt;), reading five fields per container: Compose service name, &lt;code&gt;State.Status&lt;/code&gt;, &lt;code&gt;State.ExitCode&lt;/code&gt;, &lt;code&gt;RestartCount&lt;/code&gt;, and &lt;code&gt;State.Health.Status&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Instead of declaring success on the first green poll, &lt;code&gt;ReadinessTracker&lt;/code&gt; requires &lt;strong&gt;every service&lt;/strong&gt; to remain ready with &lt;strong&gt;zero new restarts&lt;/strong&gt; across at least &lt;strong&gt;3 consecutive samples&lt;/strong&gt; (&lt;code&gt;APP_READY_STABLE_SAMPLES&lt;/code&gt;) spanning at least &lt;strong&gt;20 seconds&lt;/strong&gt; (&lt;code&gt;APP_READY_STABLE_MS&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker compose up -d
        |
        v
Poll docker inspect every 5s (ReadinessTracker)
        |
        +--&amp;gt; Boot phase: all services not up together yet
        |      └─ backstop limit: 3x restartLimit (default: 18)
        |
        +--&amp;gt; All services ready at once -&amp;gt; reset post-boot restart baseline
        |      ├─ any service hits restartLimit (default: 6) -&amp;gt; fail: APP_RESTART_LOOP
        |      ├─ same container unhealthy &amp;gt;= 60s &amp;amp; &amp;gt;= 3 polls -&amp;gt; fail: APP_UNHEALTHY
        |      └─ all ready, 0 new restarts for &amp;gt;= 20s &amp;amp; &amp;gt;= 3 polls -&amp;gt; container ready
        |
        v
Run HTTP health probe (throwaway curl container on proxy network)
        |
        v
Sample docker inspect one final time (catches crashes during probe)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two small classification rules prevent common Compose false positives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One-shot containers (&lt;code&gt;exited&lt;/code&gt; with code &lt;code&gt;0&lt;/code&gt;):&lt;/strong&gt; Database migration or setup jobs are meant to exit cleanly, so &lt;code&gt;exited(0)&lt;/code&gt; classifies as &lt;code&gt;ready&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-zero exits (&lt;code&gt;exited&lt;/code&gt; with code &lt;code&gt;!= 0&lt;/code&gt;):&lt;/strong&gt; A container in the middle of being restarted by Docker can briefly appear as &lt;code&gt;exited&lt;/code&gt; on one poll. Nitrobase only fails it as crashed if it stays &lt;code&gt;exited&lt;/code&gt; with the same exit code and restart count for &lt;strong&gt;two consecutive samples&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Two-phase restart counting: why boot retries are not crash loops
&lt;/h2&gt;

&lt;p&gt;On a fresh boot of a multi-container app, services that depend on a database routinely crash and restart a couple of times while Postgres or MySQL finishes initializing. Many upstream Compose files intentionally rely on &lt;code&gt;restart: unless-stopped&lt;/code&gt; as their retry loop.&lt;/p&gt;

&lt;p&gt;If you count every restart from second zero against a strict limit, healthy apps fail their first deploy. Worse, you cannot just track "was this individual service seen &lt;code&gt;running&lt;/code&gt; once?", because a retrying web container &lt;em&gt;is&lt;/em&gt; briefly &lt;code&gt;running&lt;/code&gt; between failed database connection attempts.&lt;/p&gt;

&lt;p&gt;Nitrobase solves this by splitting restart tracking into two phases:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Phase&lt;/th&gt;
&lt;th&gt;When it applies&lt;/th&gt;
&lt;th&gt;Failure threshold&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Boot phase&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Before &lt;em&gt;every&lt;/em&gt; service is ready simultaneously&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;3 × restartLimit&lt;/code&gt; (default &lt;code&gt;18&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Allows legitimate dependency retries while still failing fast instead of waiting out the full 5-minute timeout&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Post-boot phase&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Starts on the first sample where &lt;em&gt;every&lt;/em&gt; service is ready at once (fresh &lt;code&gt;RestartCounter&lt;/code&gt; baseline)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;restartLimit&lt;/code&gt; (default &lt;code&gt;6&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Catches true crash loops once the stack has booted; fewer restarts still emit a &lt;code&gt;job.warning&lt;/code&gt; naming the service (&lt;code&gt;api (↻2)&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If a container is recreated mid-wait and Docker resets its &lt;code&gt;RestartCount&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;RestartCounter&lt;/code&gt; automatically re-bases so deltas never go negative.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give slow &lt;code&gt;unhealthy&lt;/code&gt; containers a grace window
&lt;/h2&gt;

&lt;p&gt;Docker marks a container &lt;code&gt;unhealthy&lt;/code&gt; once its &lt;code&gt;start_period&lt;/code&gt; plus &lt;code&gt;retries&lt;/code&gt; have elapsed. On a small VPS with cold caches or heavy first-run migrations, a service can briefly flip &lt;code&gt;unhealthy&lt;/code&gt; and recover on the very next healthcheck.&lt;/p&gt;

&lt;p&gt;Rather than failing on the first &lt;code&gt;unhealthy&lt;/code&gt; poll, &lt;code&gt;ReadinessTracker&lt;/code&gt; tracks a per-service unhealthy streak bound to the container's current restart count:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A service only fails as &lt;code&gt;APP_UNHEALTHY&lt;/code&gt; if the &lt;em&gt;same&lt;/em&gt; container instance stays &lt;code&gt;unhealthy&lt;/code&gt; continuously for at least &lt;strong&gt;60 seconds&lt;/strong&gt; (&lt;code&gt;APP_UNHEALTHY_GRACE_MS&lt;/code&gt;) across at least &lt;strong&gt;3 consecutive samples&lt;/strong&gt; (&lt;code&gt;APP_UNHEALTHY_SAMPLES&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;If the container restarts or recovers, its unhealthy streak resets.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dead&lt;/code&gt; containers fail immediately.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the container stability window passes, Nitrobase runs an isolated HTTP probe from a throwaway &lt;code&gt;curl&lt;/code&gt; container attached to the proxy network—and then runs &lt;strong&gt;one final &lt;code&gt;docker inspect&lt;/code&gt; sample&lt;/strong&gt; afterward, because a slow probe can take several seconds during which a fragile service might crash.&lt;/p&gt;

&lt;h2&gt;
  
  
  Catching silent OOM kills without falling for stale flags
&lt;/h2&gt;

&lt;p&gt;When a container hits its memory limit, the Linux kernel terminates it with &lt;code&gt;SIGKILL&lt;/code&gt;. Often the application never gets a chance to flush a single error line to logs—you just see exit code &lt;code&gt;137&lt;/code&gt; and a restart loop.&lt;/p&gt;

&lt;p&gt;Docker exposes &lt;code&gt;State.OOMKilled&lt;/code&gt;, which looks straightforward until you run into two traps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;State.OOMKilled&lt;/code&gt; is sticky.&lt;/strong&gt; Docker sets it for the container's &lt;em&gt;last exit&lt;/em&gt; and keeps it &lt;code&gt;true&lt;/code&gt; until the container exits again or is recreated. If a container was OOM-killed three days ago and fails today because of a bad config change, naively reading &lt;code&gt;State.OOMKilled&lt;/code&gt; blames memory when memory had nothing to do with it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Host vs. container OOM.&lt;/strong&gt; If &lt;code&gt;HostConfig.Memory&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt; (no container limit configured), the &lt;em&gt;host&lt;/em&gt; ran out of RAM—telling the user to "raise the container's memory limit" is wrong advice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Nitrobase's &lt;code&gt;composeOomCommand&lt;/code&gt; inspects only container labels and state (never env vars or secrets) and prints the &lt;strong&gt;host's own clock first&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;now&amp;lt;TAB&amp;gt;1795694400
api&amp;lt;TAB&amp;gt;true&amp;lt;TAB&amp;gt;536870912&amp;lt;TAB&amp;gt;2026-11-26T12:00:05.123456789Z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;parseOomKills&lt;/code&gt; then applies three filters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compares &lt;code&gt;State.FinishedAt&lt;/code&gt; against &lt;code&gt;now - withinSeconds&lt;/code&gt; using the &lt;strong&gt;host's own clock&lt;/strong&gt;, eliminating clock skew between the control plane and the VPS while ignoring stale OOM kills from before the deploy started.&lt;/li&gt;
&lt;li&gt;Ignores any kill where &lt;code&gt;HostConfig.Memory &amp;lt;= 0&lt;/code&gt; so container-limit hints only appear when a container limit actually caused the kill.&lt;/li&gt;
&lt;li&gt;Pairs OOM checks with coded log failure signatures (&lt;code&gt;FailureHints&lt;/code&gt;) without ever copying raw container logs (which may contain secrets) into the job event stream.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What deploy readiness checks still cannot prove
&lt;/h2&gt;

&lt;p&gt;Container stability and a passing HTTP probe confirm that your processes booted cleanly and answered requests without crashing during the wait window. They cannot catch slow memory leaks that OOM three hours later, background worker deadlocks with no healthcheck, or subtle application-level data bugs. Those belong to continuous monitoring and app-level tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  My checklist for reliable Compose deploy readiness
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Never treat &lt;code&gt;docker compose up -d&lt;/code&gt; exit code &lt;code&gt;0&lt;/code&gt; or a single &lt;code&gt;docker inspect&lt;/code&gt; poll as "ready"&lt;/li&gt;
&lt;li&gt;Require a multi-sample stability window (&lt;code&gt;running&lt;/code&gt; / &lt;code&gt;healthy&lt;/code&gt;, zero new restarts) before declaring success&lt;/li&gt;
&lt;li&gt;Separate boot-time dependency retries from post-boot crash loops so healthy first boots do not false-fail&lt;/li&gt;
&lt;li&gt;Handle one-shot migration containers (&lt;code&gt;exited(0)&lt;/code&gt;) and require two samples before failing non-zero exits&lt;/li&gt;
&lt;li&gt;Re-sample container status &lt;em&gt;after&lt;/em&gt; running HTTP probes&lt;/li&gt;
&lt;li&gt;Filter &lt;code&gt;State.OOMKilled&lt;/code&gt; by &lt;code&gt;State.FinishedAt&lt;/code&gt; on the host's own clock and verify &lt;code&gt;HostConfig.Memory &amp;gt; 0&lt;/code&gt; before blaming a container limit&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exit code &lt;code&gt;0&lt;/code&gt; means Docker accepted your request. Watching stability, restarts, health streaks, and OOM timestamps over time tells you whether your app actually survived startup.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>selfhosted</category>
      <category>linux</category>
    </item>
    <item>
      <title>Why a Regex Is Never Enough for a Read-Only SQL Console</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Wed, 25 Nov 2026 09:34:52 +0000</pubDate>
      <link>https://dev.to/hoagminh/why-a-regex-is-never-enough-for-a-read-only-sql-console-24lg</link>
      <guid>https://dev.to/hoagminh/why-a-regex-is-never-enough-for-a-read-only-sql-console-24lg</guid>
      <description>&lt;p&gt;Almost every self-hosted admin panel eventually adds a "Run SQL" tab with a &lt;strong&gt;Read-Only&lt;/strong&gt; toggle.&lt;/p&gt;

&lt;p&gt;The first prototype almost always looks the same: trim the query, check whether it starts with &lt;code&gt;SELECT&lt;/code&gt;, and pipe it into &lt;code&gt;psql&lt;/code&gt; or &lt;code&gt;mysql&lt;/code&gt; inside the database container.&lt;/p&gt;

&lt;p&gt;It works for five minutes—until someone sends one of these:&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="c1"&gt;-- 1. Client meta-command (runs a shell inside the container, not SQL)&lt;/span&gt;
\&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;

&lt;span class="c1"&gt;-- 2. Transaction breakout&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;COMMIT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;DROP&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- 3. MySQL executable comment (looks like a comment, executes on the server)&lt;/span&gt;
&lt;span class="cm"&gt;/*!50000 DROP TABLE users */&lt;/span&gt;

&lt;span class="c1"&gt;-- 4. Postgres nested block comments &amp;amp; dollar quotes hiding semicolons&lt;/span&gt;
&lt;span class="cm"&gt;/* outer /* inner */&lt;/span&gt; &lt;span class="o"&gt;*/&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; $$ &lt;span class="p"&gt;;&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;FROM&lt;/span&gt; &lt;span class="n"&gt;sessions&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even when nobody is trying to break out, a single accidental &lt;code&gt;SELECT * FROM events&lt;/code&gt; on a 10-million-row table can stream gigabytes back into your control plane and OOM-kill the dashboard.&lt;/p&gt;

&lt;p&gt;This is the design behind the &lt;strong&gt;database console&lt;/strong&gt; in Nitrobase.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. Its console is not a replacement for a full desktop SQL IDE. The goal is narrower: let you inspect production PostgreSQL, MySQL, and MariaDB databases directly from the browser while enforcing read-only safety inside the database engine itself—not just in a JavaScript parser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 1: Treat the SQL lexer as a guardrail, never the security boundary
&lt;/h2&gt;

&lt;p&gt;Nitrobase does parse the input before anything touches a container (&lt;code&gt;scanSql&lt;/code&gt; and &lt;code&gt;checkConsoleSql&lt;/code&gt;), using a dialect-aware lexer rather than a naive &lt;code&gt;.split(";")&lt;/code&gt; or &lt;code&gt;^SELECT&lt;/code&gt; regex:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PostgreSQL dialect:&lt;/strong&gt; Handles nested &lt;code&gt;/* /* ... */ */&lt;/code&gt; block comments, dollar-quoted strings (&lt;code&gt;$$...$$&lt;/code&gt; and &lt;code&gt;$tag$...$tag$&lt;/code&gt;), and &lt;code&gt;E'...'&lt;/code&gt; backslash escapes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MySQL / MariaDB dialect:&lt;/strong&gt; Handles &lt;code&gt;#&lt;/code&gt; line comments, backtick-quoted identifiers, and flags server-executed comments (&lt;code&gt;/*! ... */&lt;/code&gt; and MariaDB &lt;code&gt;/*M! ... */&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client command blocking:&lt;/strong&gt; Rejects any backslash outside strings/comments (&lt;code&gt;\!&lt;/code&gt;, &lt;code&gt;\copy&lt;/code&gt;, &lt;code&gt;\i&lt;/code&gt;) and blocks MySQL CLI commands (&lt;code&gt;SYSTEM&lt;/code&gt;, &lt;code&gt;SOURCE&lt;/code&gt;, &lt;code&gt;TEE&lt;/code&gt;, &lt;code&gt;PAGER&lt;/code&gt;, &lt;code&gt;DELIMITER&lt;/code&gt;, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read-only rules:&lt;/strong&gt; In Postgres, refuses transaction control (&lt;code&gt;BEGIN&lt;/code&gt;, &lt;code&gt;COMMIT&lt;/code&gt;, &lt;code&gt;ROLLBACK&lt;/code&gt;, &lt;code&gt;SAVEPOINT&lt;/code&gt;, &lt;code&gt;PREPARE&lt;/code&gt;) and session/role overrides (&lt;code&gt;SET ROLE&lt;/code&gt;, &lt;code&gt;SET SESSION AUTHORIZATION&lt;/code&gt;, &lt;code&gt;SET TRANSACTION&lt;/code&gt;, &lt;code&gt;SET default_transaction_read_only&lt;/code&gt;). In MySQL/MariaDB, restricts statements to an explicit read-only allowlist (&lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;SHOW&lt;/code&gt;, &lt;code&gt;DESCRIBE&lt;/code&gt;, &lt;code&gt;EXPLAIN&lt;/code&gt;, &lt;code&gt;WITH&lt;/code&gt;, &lt;code&gt;TABLE&lt;/code&gt;, &lt;code&gt;VALUES&lt;/code&gt;, &lt;code&gt;USE&lt;/code&gt;) and blocks &lt;code&gt;INTO OUTFILE&lt;/code&gt; / &lt;code&gt;INTO DUMPFILE&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why bother writing a real lexer if it is not the security boundary? Two reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Clear, immediate feedback&lt;/strong&gt; before spawning a container process (for example, refusing an unterminated dollar quote or a &lt;code&gt;mysql&lt;/code&gt; client command with a specific error code).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safe audit logging (&lt;code&gt;maskSqlLiterals&lt;/code&gt;):&lt;/strong&gt; Every string literal and dollar-quoted body is replaced with &lt;code&gt;'…'&lt;/code&gt; before logging—so a write-mode &lt;code&gt;ALTER ROLE app PASSWORD '...'&lt;/code&gt; never leaks plaintext credentials into audit history. If the SQL cannot even be tokenized (unterminated quote), it fails closed by masking everything from the first quote onward.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Still, any parser can have edge cases—such as a &lt;code&gt;SELECT&lt;/code&gt; calling a volatile function with side effects. That is why the real enforcement lives in Layer 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 2: Enforce read-only inside the database engine
&lt;/h2&gt;

&lt;p&gt;When a query runs in read-only mode, Nitrobase does &lt;strong&gt;not&lt;/strong&gt; log in as the database superuser or root account. Instead, after every deploy, it idempotently provisions a dedicated least-privilege role (&lt;code&gt;nitrobase_console&lt;/code&gt;) per engine:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Engine&lt;/th&gt;
&lt;th&gt;Read-only role &amp;amp; isolation&lt;/th&gt;
&lt;th&gt;Transaction &amp;amp; timeout guard&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PostgreSQL&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;nitrobase_console&lt;/code&gt; with &lt;code&gt;NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS&lt;/code&gt;, &lt;code&gt;PASSWORD NULL&lt;/code&gt; (blocks TCP SCRAM logins; container Unix socket only), &lt;code&gt;pg_read_all_data&lt;/code&gt; + &lt;code&gt;pg_read_all_stats&lt;/code&gt;, and &lt;code&gt;default_transaction_read_only = on&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;PGOPTIONS&lt;/code&gt; sets &lt;code&gt;default_transaction_read_only=on&lt;/code&gt; and &lt;code&gt;statement_timeout&lt;/code&gt;; executed via &lt;code&gt;psql -c 'BEGIN' -c 'SET TRANSACTION READ ONLY' -c "SET LOCAL statement_timeout = ..." -c "$sql" -c 'ROLLBACK'&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MySQL 8&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;'nitrobase_console'@'localhost'&lt;/code&gt; via &lt;code&gt;--protocol=socket&lt;/code&gt;, &lt;code&gt;SET PERSIST partial_revokes = ON&lt;/code&gt;, &lt;code&gt;GRANT SELECT, SHOW VIEW ON *.*&lt;/code&gt;, then &lt;code&gt;REVOKE SELECT, SHOW VIEW ON mysql.*&lt;/code&gt; (cannot read &lt;code&gt;mysql.user&lt;/code&gt; password hashes)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;SET SESSION TRANSACTION READ ONLY&lt;/code&gt;, &lt;code&gt;SET SESSION max_execution_time&lt;/code&gt;, &lt;code&gt;START TRANSACTION READ ONLY&lt;/code&gt;, ending with &lt;code&gt;ROLLBACK&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MariaDB&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;'nitrobase_console'@'localhost'&lt;/code&gt; via &lt;code&gt;--protocol=socket&lt;/code&gt; (since MariaDB lacks &lt;code&gt;partial_revokes&lt;/code&gt;, Nitrobase refreshes per-database &lt;code&gt;SELECT, SHOW VIEW&lt;/code&gt; grants excluding &lt;code&gt;mysql&lt;/code&gt;, &lt;code&gt;information_schema&lt;/code&gt;, &lt;code&gt;performance_schema&lt;/code&gt;, &lt;code&gt;sys&lt;/code&gt; before each read-only run)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;SET SESSION TRANSACTION READ ONLY&lt;/code&gt;, &lt;code&gt;SET SESSION max_statement_time&lt;/code&gt;, &lt;code&gt;START TRANSACTION READ ONLY&lt;/code&gt;, ending with &lt;code&gt;ROLLBACK&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two subtle details here matter more than they look at first glance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Passing SQL via &lt;code&gt;psql -c "$sql"&lt;/code&gt; (read from &lt;code&gt;stdin&lt;/code&gt;, never argv):&lt;/strong&gt; Because &lt;code&gt;psql&lt;/code&gt; never interprets backslash meta-commands inside &lt;code&gt;-c&lt;/code&gt;, even if a backslash somehow slipped past validation, &lt;code&gt;\! sh&lt;/code&gt; is rejected as invalid SQL instead of spawning a shell. Meanwhile, reading the SQL from &lt;code&gt;stdin&lt;/code&gt; keeps queries and passwords out of &lt;code&gt;ps&lt;/code&gt; output on the host (&lt;code&gt;MYSQL_PWD&lt;/code&gt; is likewise read from an environment variable inside the container, never passed as &lt;code&gt;-p&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Locking out &lt;code&gt;mysql.*&lt;/code&gt; and TCP logins:&lt;/strong&gt; A "read-only" MySQL user with &lt;code&gt;SELECT ON *.*&lt;/code&gt; can still read password hashes from &lt;code&gt;mysql.user&lt;/code&gt; unless &lt;code&gt;mysql.*&lt;/code&gt; is explicitly revoked. And giving Postgres's &lt;code&gt;nitrobase_console&lt;/code&gt; &lt;code&gt;PASSWORD NULL&lt;/code&gt; guarantees it can never authenticate over TCP—only via &lt;code&gt;docker exec&lt;/code&gt; on the local Unix socket.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Layer 3: Cap stdout and stderr &lt;em&gt;inside&lt;/em&gt; the container
&lt;/h2&gt;

&lt;p&gt;Preventing writes is only half the problem. Preventing a huge query from crashing the control plane is the other half.&lt;/p&gt;

&lt;p&gt;If you let &lt;code&gt;docker exec&lt;/code&gt; run uncapped and truncate output in Node.js afterward, the database client still reads and serializes the entire table across SSH into memory. Instead, Nitrobase wraps the database client in a small POSIX &lt;code&gt;sh&lt;/code&gt; pipeline inside the container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -i &amp;lt;container&amp;gt; sh -c '...'
   │
   ├── stdout ──► head -c &amp;lt;maxBytes&amp;gt; ──► triggers SIGPIPE (stops DB client early)
   │                ▲
   │                └── appends "\n__nitrobase_exit_&amp;lt;nonce&amp;gt;__:&amp;lt;exitCode&amp;gt;" via FD 4
   │
   └── stderr ──► tail -c &amp;lt;maxErrorBytes&amp;gt; ──► drains NOTICE floods, keeps final ERROR
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look closely at what that FD redirection gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;head -c&lt;/code&gt; on stdout&lt;/strong&gt; stops reading as soon as the byte cap is reached, sending &lt;code&gt;SIGPIPE&lt;/code&gt; back to &lt;code&gt;psql&lt;/code&gt; or &lt;code&gt;mysql&lt;/code&gt; so a runaway &lt;code&gt;SELECT *&lt;/code&gt; stops immediately inside the container.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;tail -c&lt;/code&gt; on stderr&lt;/strong&gt; drains noisy &lt;code&gt;NOTICE&lt;/code&gt; floods without buffering them in the panel's RAM, while keeping the &lt;em&gt;last&lt;/em&gt; bytes where the actual &lt;code&gt;ERROR:&lt;/code&gt; line lives.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A per-run random hex nonce marker (&lt;code&gt;__nitrobase_exit_&amp;lt;nonce&amp;gt;__:&amp;lt;status&amp;gt;&lt;/code&gt;)&lt;/strong&gt; follows the client output on stdout. Query results cannot spoof it, and if &lt;code&gt;head -c&lt;/code&gt; truncated stdout before the marker arrived, Nitrobase immediately sees the marker is missing and marks the result as truncated (backed up by a second byte-capped collector on the Node side as well).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For MySQL/MariaDB multi-statement scripts, Nitrobase uses the same nonce trick (&lt;code&gt;SELECT '__nitrobase_result_&amp;lt;nonce&amp;gt;__' AS ...&lt;/code&gt;) right before the final statement so the parser cleanly isolates the last result set from earlier statements.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this design still does not solve
&lt;/h2&gt;

&lt;p&gt;A read-only transaction and byte cap protect data integrity and panel memory, not database CPU or I/O completely. An unindexed &lt;code&gt;CROSS JOIN&lt;/code&gt; can still consume CPU until &lt;code&gt;statement_timeout&lt;/code&gt; or &lt;code&gt;max_execution_time&lt;/code&gt; fires.&lt;/p&gt;

&lt;p&gt;And when a user explicitly switches the console to &lt;strong&gt;Write mode&lt;/strong&gt;, Nitrobase connects as the database's main superuser/root account—at that point the safety net is intentionally off, relying on explicit mode confirmation and literal-masked audit logs rather than query restrictions.&lt;/p&gt;

&lt;h2&gt;
  
  
  My checklist for building a browser SQL console
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Never trust a regex or &lt;code&gt;.split(";")&lt;/code&gt; as your read-only security boundary&lt;/li&gt;
&lt;li&gt;Block client meta-commands (&lt;code&gt;psql&lt;/code&gt; &lt;code&gt;\!&lt;/code&gt;, &lt;code&gt;mysql&lt;/code&gt; &lt;code&gt;SYSTEM&lt;/code&gt;/&lt;code&gt;SOURCE&lt;/code&gt;) and avoid passing raw SQL or passwords on CLI argv&lt;/li&gt;
&lt;li&gt;Run read-only queries under a dedicated least-privilege DB role inside a &lt;code&gt;READ ONLY&lt;/code&gt; transaction with a server-side statement timeout&lt;/li&gt;
&lt;li&gt;Restrict the read-only role from reading system credential tables (&lt;code&gt;mysql.*&lt;/code&gt;) and lock it to local socket access where possible&lt;/li&gt;
&lt;li&gt;Cap stdout (&lt;code&gt;head -c&lt;/code&gt; + &lt;code&gt;SIGPIPE&lt;/code&gt;) and stderr (&lt;code&gt;tail -c&lt;/code&gt;) &lt;em&gt;inside&lt;/em&gt; the container, using a per-run nonce marker to detect truncation cleanly&lt;/li&gt;
&lt;li&gt;Mask string literals (and fail closed on malformed SQL) before writing queries to audit logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A regex checks what a query &lt;em&gt;looks like&lt;/em&gt;. Enforcing roles, transactions, and stream caps inside the container checks what it can &lt;em&gt;actually do&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>mysql</category>
      <category>security</category>
      <category>devops</category>
    </item>
    <item>
      <title>TRAEFIK DEFAULT CERT Is Not an Error Message: Diagnosing DNS and TLS on a VPS</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Tue, 24 Nov 2026 14:47:15 +0000</pubDate>
      <link>https://dev.to/hoagminh/traefik-default-cert-is-not-an-error-message-diagnosing-dns-and-tls-on-a-vps-37jo</link>
      <guid>https://dev.to/hoagminh/traefik-default-cert-is-not-an-error-message-diagnosing-dns-and-tls-on-a-vps-37jo</guid>
      <description>&lt;p&gt;Almost everyone who has self-hosted an application behind Traefik has seen the same browser screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your connection is not private
NET::ERR_CERT_AUTHORITY_INVALID
Issuer: TRAEFIK DEFAULT CERT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser tells you the certificate is untrusted. It does not tell you &lt;em&gt;why&lt;/em&gt; Let's Encrypt failed to issue one.&lt;/p&gt;

&lt;p&gt;Maybe the domain has no DNS record yet. Maybe the &lt;code&gt;A&lt;/code&gt; record points to the right VPS, while a forgotten &lt;code&gt;AAAA&lt;/code&gt; record still points to an old server. Maybe port &lt;code&gt;443&lt;/code&gt; is blocked by a firewall. Maybe the domain is behind a Cloudflare Tunnel where an &lt;code&gt;A&lt;/code&gt; record makes no sense at all. Maybe the certificate was issued—against Let's Encrypt's staging CA.&lt;/p&gt;

&lt;p&gt;When you only show a generic red "HTTPS failed" badge, every one of those problems looks identical.&lt;/p&gt;

&lt;p&gt;This is the problem behind &lt;strong&gt;domain and TLS diagnostics&lt;/strong&gt; in Nitrobase.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. Its domain checker registry does not replace full external uptime monitoring, and it cannot fix DNS records inside your registrar. Its job is narrower: probe the real DNS and TLS state so a self-hoster can see &lt;em&gt;which layer&lt;/em&gt; broke in seconds instead of guessing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate DNS, Tunnel, and TLS into independent checks
&lt;/h2&gt;

&lt;p&gt;A domain route in Nitrobase passes through a small registry of checkers (&lt;code&gt;dns&lt;/code&gt;, &lt;code&gt;tunnel&lt;/code&gt;, &lt;code&gt;cert&lt;/code&gt;), where each checker declares whether it applies to a given route:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Checker&lt;/th&gt;
&lt;th&gt;When it runs&lt;/th&gt;
&lt;th&gt;What it verifies&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;dns&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Public VPS routes (&lt;code&gt;!viaTunnel&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Resolves both &lt;code&gt;A&lt;/code&gt; (IPv4) and &lt;code&gt;AAAA&lt;/code&gt; (IPv6) records against the server's public IPs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tunnel&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Cloudflare Tunnel routes (&lt;code&gt;viaTunnel&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Reports the live &lt;code&gt;cloudflared&lt;/code&gt; connector state instead of expecting a VPS &lt;code&gt;A&lt;/code&gt; record&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cert&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Any route with HTTPS enabled&lt;/td&gt;
&lt;td&gt;Performs a live TLS handshake on port &lt;code&gt;443&lt;/code&gt; and inspects the peer certificate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That &lt;code&gt;appliesTo&lt;/code&gt; split prevents a common false alarm. A domain routed through Cloudflare Tunnel uses a CNAME to Cloudflare's edge—it will never resolve to the VPS's public IP. Running a standard &lt;code&gt;A&lt;/code&gt;-record check on a tunnel hostname would permanently show a false "DNS mismatch" error, so Nitrobase swaps the &lt;code&gt;dns&lt;/code&gt; check for &lt;code&gt;tunnel&lt;/code&gt; (&lt;code&gt;connected&lt;/code&gt;, &lt;code&gt;connecting&lt;/code&gt;, &lt;code&gt;failing&lt;/code&gt;, &lt;code&gt;stopped&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  The stale &lt;code&gt;AAAA&lt;/code&gt; record trap (&lt;code&gt;dns_partial&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;One of the sneakiest Let's Encrypt failures happens when migrating a domain from an old host to a new VPS.&lt;/p&gt;

&lt;p&gt;You update the &lt;code&gt;A&lt;/code&gt; record to the new IPv4 address. You run &lt;code&gt;ping app.example.com&lt;/code&gt; from your laptop and see the new IP. Everything looks right—yet ACME certificate issuance keeps failing.&lt;/p&gt;

&lt;p&gt;The culprit is often an old &lt;code&gt;AAAA&lt;/code&gt; (IPv6) record left behind at the registrar. Let's Encrypt prefers IPv6 when an &lt;code&gt;AAAA&lt;/code&gt; record exists, so the HTTP-01 challenge hits the old server while your IPv4 &lt;code&gt;ping&lt;/code&gt; hits the new one.&lt;/p&gt;

&lt;p&gt;Nitrobase resolves IPv4 and IPv6 in parallel (&lt;code&gt;dns.resolve4&lt;/code&gt; and &lt;code&gt;dns.resolve6&lt;/code&gt;) and compares &lt;em&gt;every&lt;/em&gt; returned address against the VPS's known public IPs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Resolved DNS records vs. VPS public IPs:
  - 0 records returned            -&amp;gt; error:   dns_no_record
  - All records match server IPs  -&amp;gt; ok:      dns_ok
  - Some match, some don't        -&amp;gt; warning: dns_partial  (classic stale AAAA / old IP!)
  - None match server IPs         -&amp;gt; error:   dns_mismatch (shows resolved vs. expected)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Surfacing &lt;code&gt;dns_partial&lt;/code&gt; with both the resolved list and the matching subset turns a thirty-minute mystery into a ten-second fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the TLS probe deliberately uses &lt;code&gt;rejectUnauthorized: false&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;If you test HTTPS with a standard &lt;code&gt;fetch("https://app.example.com")&lt;/code&gt; or a strict &lt;code&gt;tls.connect()&lt;/code&gt;, Node throws an opaque handshake error the moment a certificate is self-signed or expired. You learn that TLS failed, but you lose the certificate itself.&lt;/p&gt;

&lt;p&gt;Nitrobase's &lt;code&gt;certChecker&lt;/code&gt; opens a raw &lt;code&gt;tls.connect()&lt;/code&gt; socket on port &lt;code&gt;443&lt;/code&gt; with SNI (&lt;code&gt;servername&lt;/code&gt;) set to the hostname and &lt;code&gt;rejectUnauthorized: false&lt;/code&gt;—strictly for read-only certificate inspection, never for sending application requests or credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tls.connect({ host, port: 443, servername, rejectUnauthorized: false })
        |
        v
Read socket.getPeerCertificate() + socket.authorized
        |
        +--&amp;gt; validTo &amp;lt; now                           -&amp;gt; error:   cert_expired
        +--&amp;gt; !authorized &amp;amp;&amp;amp; /TRAEFIK DEFAULT CERT/   -&amp;gt; error:   cert_default
        +--&amp;gt; !authorized (other issuer/error)        -&amp;gt; error:   cert_untrusted
        +--&amp;gt; /STAGING|Fake LE/i.test(issuer)         -&amp;gt; warning: cert_staging
        +--&amp;gt; expires within warningDays              -&amp;gt; warning: cert_expiring
        +--&amp;gt; authorized &amp;amp; healthy                    -&amp;gt; ok:      cert_ok
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That single distinction between &lt;code&gt;cert_default&lt;/code&gt; and &lt;code&gt;cert_untrusted&lt;/code&gt; saves real time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;cert_default&lt;/code&gt; (&lt;code&gt;TRAEFIK DEFAULT CERT&lt;/code&gt;):&lt;/strong&gt; Traefik is reachable on port &lt;code&gt;443&lt;/code&gt;, which means your firewall and routing are working—ACME just hasn't finished issuing (or couldn't validate) the Let's Encrypt certificate yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;cert_untrusted&lt;/code&gt;:&lt;/strong&gt; Something else answered on port &lt;code&gt;443&lt;/code&gt; (a misconfigured proxy, a self-signed origin cert, or a wrong host).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;cert_unreachable&lt;/code&gt;:&lt;/strong&gt; The TCP/TLS connection timed out or refused connection entirely—check port &lt;code&gt;443&lt;/code&gt; firewall rules or whether Traefik is running.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;cert_staging&lt;/code&gt;:&lt;/strong&gt; HTTPS appears to work in some tools, but the certificate came from Let's Encrypt's staging CA (&lt;code&gt;Fake LE&lt;/code&gt;) and browsers will reject it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;cert_expiring&lt;/code&gt;:&lt;/strong&gt; The certificate is valid today, but approaching expiration—giving you early warning if automated renewal stopped working.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Testing real HTTPS before buying a domain
&lt;/h2&gt;

&lt;p&gt;Sometimes you just want to deploy an app on a fresh VPS and verify HTTPS end-to-end without touching a registrar first.&lt;/p&gt;

&lt;p&gt;Nitrobase supports zero-setup wildcard DNS providers (&lt;code&gt;sslip.io&lt;/code&gt; for IPv4/IPv6 and &lt;code&gt;nip.io&lt;/code&gt; for IPv4), turning a server IP like &lt;code&gt;203.0.113.10&lt;/code&gt; into a resolvable hostname (&lt;code&gt;my-app.203-0-113-10.sslip.io&lt;/code&gt;) automatically. Combined with a real ACME email (&lt;code&gt;ACME_EMAIL&lt;/code&gt;, falling back to the admin's account email rather than placeholder domains like &lt;code&gt;example.com&lt;/code&gt; that Let's Encrypt rejects), you can test live TLS certificates immediately on a brand-new server.&lt;/p&gt;

&lt;h2&gt;
  
  
  What domain checks still cannot see
&lt;/h2&gt;

&lt;p&gt;DNS propagation is global and cached by recursive resolvers. A check running from the Nitrobase control plane sees what &lt;em&gt;its&lt;/em&gt; resolver sees—your local ISP or Let's Encrypt's multi-perspective validation servers may still hold a cached record for a few minutes.&lt;/p&gt;

&lt;p&gt;Likewise, &lt;code&gt;certChecker&lt;/code&gt; verifies the certificate presented on port &lt;code&gt;443&lt;/code&gt;, not whether the application container behind Traefik is returning HTTP &lt;code&gt;200&lt;/code&gt; (which belongs to application health checks).&lt;/p&gt;

&lt;h2&gt;
  
  
  My checklist when HTTPS won't issue on a VPS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Do &lt;em&gt;both&lt;/em&gt; &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;AAAA&lt;/code&gt; records point exclusively to this VPS (no leftover IPv6 record)?&lt;/li&gt;
&lt;li&gt;[ ] Is the domain routed through Cloudflare Tunnel instead of direct public ports?&lt;/li&gt;
&lt;li&gt;[ ] Is port &lt;code&gt;443&lt;/code&gt; (and &lt;code&gt;80&lt;/code&gt; for HTTP-01 challenges) open on the host and cloud firewall?&lt;/li&gt;
&lt;li&gt;[ ] Is Traefik returning &lt;code&gt;TRAEFIK DEFAULT CERT&lt;/code&gt; (ACME pending/failed) or is another service answering?&lt;/li&gt;
&lt;li&gt;[ ] Is the ACME account configured with a real, non-placeholder email address?&lt;/li&gt;
&lt;li&gt;[ ] Is the issued cert from production Let's Encrypt rather than &lt;code&gt;Fake LE&lt;/code&gt; staging?&lt;/li&gt;
&lt;li&gt;[ ] Will you notice &lt;em&gt;before&lt;/em&gt; expiry if renewal breaks 60 days from now?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Good diagnostics don't make TLS magic. They just replace "connection not private" with the exact reason so you know which screen to open next.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>selfhosted</category>
      <category>networking</category>
      <category>tls</category>
    </item>
    <item>
      <title>Why Closing an SSH Channel Does Not Kill the Command Running Inside It</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Mon, 23 Nov 2026 14:25:42 +0000</pubDate>
      <link>https://dev.to/hoagminh/why-closing-an-ssh-channel-does-not-kill-the-command-running-inside-it-50kl</link>
      <guid>https://dev.to/hoagminh/why-closing-an-ssh-channel-does-not-kill-the-command-running-inside-it-50kl</guid>
      <description>&lt;p&gt;When you build a self-hosted PaaS, nearly everything important travels over SSH.&lt;/p&gt;

&lt;p&gt;Bootstrapping Docker. Uploading a Compose file. Streaming a backup archive. Cancelling a build that took too long.&lt;/p&gt;

&lt;p&gt;Early on, it is tempting to wrap &lt;code&gt;ssh2&lt;/code&gt; in a small helper:&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="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stream&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="c1"&gt;// collect stdout and stderr&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 abstraction holds until the first time a user clicks &lt;strong&gt;Cancel&lt;/strong&gt; during a slow &lt;code&gt;docker compose build&lt;/code&gt;, or a command hangs inside a broken container, or a file write touches a symlinked directory on the remote host.&lt;/p&gt;

&lt;p&gt;Closing the SSH channel does not necessarily stop the remote process tree.&lt;/p&gt;

&lt;p&gt;These problems shaped the &lt;strong&gt;SSH executor and managed-file scripts&lt;/strong&gt; in Nitrobase.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. SSH automation still relies on trusted server credentials and OS behavior, so the executor focuses on making cancellation, host verification, and remote file writes predictable rather than pretending SSH is a sandbox.&lt;/p&gt;

&lt;h2&gt;
  
  
  OpenSSH does not always honor channel signals
&lt;/h2&gt;

&lt;p&gt;The SSH protocol includes a &lt;code&gt;signal&lt;/code&gt; message so a client can ask the server to send &lt;code&gt;SIGTERM&lt;/code&gt; or &lt;code&gt;SIGKILL&lt;/code&gt; to the command running inside a channel.&lt;/p&gt;

&lt;p&gt;In practice, that mechanism has two sharp edges:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;OpenSSH refuses channel signal requests on &lt;code&gt;root&lt;/code&gt; sessions&lt;/strong&gt; ("requires privilege separation") or ignores them depending on server configuration and subsystem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Closing the client stream leaves grandchildren running&lt;/strong&gt; if a shell spawned a build, &lt;code&gt;docker&lt;/code&gt;, or backup pipeline without process-group coordination.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the panel reports "Job cancelled" while &lt;code&gt;docker build&lt;/code&gt; continues consuming CPU and disk on the VPS for another ten minutes, the control plane and the server are now out of sync.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tagging the command so another channel can find the tree
&lt;/h2&gt;

&lt;p&gt;Nitrobase handles remote timeouts and cancellation from two angles in &lt;code&gt;withRemoteTimeout()&lt;/code&gt; and &lt;code&gt;SshExecutor&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Channel 1 (command):
  exec timeout --kill-after=10s 300s sh -c ': nitrobase-job-&amp;lt;tag&amp;gt;; &amp;lt;command&amp;gt;'

Cancel / Timeout fires:
  |
  +--&amp;gt; Channel 2 (signal): pkill -TERM -f nitrobase-job-&amp;lt;tag&amp;gt;
  |       |
  |       +--&amp;gt; grace period expires? --&amp;gt; pkill -KILL -f nitrobase-job-&amp;lt;tag&amp;gt;
  |
  +--&amp;gt; stream.resume() if paused for backpressure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three small details make this reliable in practice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;In-shell GNU &lt;code&gt;timeout&lt;/code&gt;:&lt;/strong&gt; Wrapping the command in &lt;code&gt;timeout --kill-after=10s&lt;/code&gt; places the job in a process group that cleanly signals child processes when the deadline expires, with a local Slack timer as a fallback if &lt;code&gt;timeout&lt;/code&gt; is missing on the host.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An innocuous &lt;code&gt;argv&lt;/code&gt; marker (&lt;code&gt;: nitrobase-job-&amp;lt;tag&amp;gt;;&lt;/code&gt;):&lt;/strong&gt; The colon built-in in POSIX &lt;code&gt;sh&lt;/code&gt; is a no-op, yet the tag remains embedded in the &lt;code&gt;sh -c&lt;/code&gt; process arguments. If a user aborts the job, Nitrobase opens a second channel on the same SSH connection and runs &lt;code&gt;pkill -TERM -f&lt;/code&gt; (then &lt;code&gt;KILL&lt;/code&gt; after a grace window) targeting that exact run's unique tag.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unblocking paused streams on abort:&lt;/strong&gt; When streaming large binary outputs like backups, backpressure may pause the SSH channel (&lt;code&gt;stream.pause()&lt;/code&gt;). On cancellation, &lt;code&gt;SshExecutor&lt;/code&gt; calls &lt;code&gt;channel.resume()&lt;/code&gt; so a blocked remote writer isn't stuck waiting on full buffers when &lt;code&gt;SIGTERM&lt;/code&gt; arrives.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The shell itself stays POSIX-quoted (&lt;code&gt;shellQuote&lt;/code&gt;) and job tags are strictly validated (&lt;code&gt;[a-z0-9]{8,32}&lt;/code&gt;) so the marker can never expand into another command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing remote files without following symlinks
&lt;/h2&gt;

&lt;p&gt;Uploading a &lt;code&gt;.env&lt;/code&gt; or &lt;code&gt;compose.yml&lt;/code&gt; file over SSH often gets written as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /etc/nitrobase/apps/my-app/compose.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That breaks silently in three ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If a parent directory or the target file was replaced by a symlink pointing to &lt;code&gt;/etc/passwd&lt;/code&gt; or another application's directory, &lt;code&gt;cat &amp;gt;&lt;/code&gt; follows the symlink and overwrites the target outside &lt;code&gt;/etc/nitrobase&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If the SSH connection drops mid-stream, the target file is left half-written.&lt;/li&gt;
&lt;li&gt;Leading or trailing whitespace in read files gets stripped if you simply &lt;code&gt;.trim()&lt;/code&gt; command stdout.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nitrobase uploads and reads managed files through &lt;code&gt;managedWriteScript()&lt;/code&gt; and &lt;code&gt;managedReadScript()&lt;/code&gt; restricted strictly to &lt;code&gt;/etc/nitrobase/&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stdin bytes
    |
    v
1. assertManagedPath()        reject "..", relative paths, outside /etc/nitrobase/
    |
    v
2. realpath -m "$dir"         refuse if any parent component is a symlink
    |
    v
3. mkdir -p &amp;amp;&amp;amp; realpath -e    re-verify resolved directory still matches
    |
    v
4. mktemp -&amp;gt; cat -&amp;gt; chmod     write safely to a temp file in the same dir
    |
    v
5. mv -fT "$tmp" "$target"    atomic swap; -T replaces target symlink instead of following
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look closely at step 5 (&lt;code&gt;mv -fT&lt;/code&gt;): without &lt;code&gt;-T&lt;/code&gt;, if &lt;code&gt;$target&lt;/code&gt; happens to be a symlink to a directory, &lt;code&gt;mv&lt;/code&gt; moves the temp file &lt;em&gt;inside&lt;/em&gt; that directory instead of replacing the path itself. And on reads, &lt;code&gt;managedReadScript()&lt;/code&gt; verifies &lt;code&gt;realpath -e&lt;/code&gt; equals the path, checks &lt;code&gt;-f&lt;/code&gt; (regular file), and outputs &lt;code&gt;base64&lt;/code&gt; so every trailing newline survives stdout trimming intact.&lt;/p&gt;

&lt;h2&gt;
  
  
  Host key verification is not &lt;code&gt;() =&amp;gt; true&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Many SSH client examples include one fatal shortcut:&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="c1"&gt;// Silent MITM vulnerability&lt;/span&gt;
&lt;span class="n"&gt;hostVerifier&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="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Disabling host-key checks turns every automated deployment into an unauthenticated connection vulnerable to man-in-the-middle interception—even if the VPS was reprovisioned cleanly with a brand new identity that the administrator expects to verify.&lt;/p&gt;

&lt;p&gt;Nitrobase uses &lt;strong&gt;Trust On First Use (TOFU)&lt;/strong&gt; via &lt;code&gt;openClient()&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the very first connection to a new server (&lt;code&gt;expected&lt;/code&gt; absent), &lt;code&gt;hostVerifier&lt;/code&gt; computes the SHA-256 fingerprint and persists it via &lt;code&gt;onFirstSeen&lt;/code&gt; &lt;em&gt;before&lt;/em&gt; resolving the connection as ready.&lt;/li&gt;
&lt;li&gt;Every subsequent command, test, or shell session compares the observed key against the stored fingerprint.&lt;/li&gt;
&lt;li&gt;If a VPS key unexpectedly changes, Nitrobase throws &lt;code&gt;HostKeyMismatchError&lt;/code&gt; and refuses the connection instead of silently trusting the new key.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One SSH connection per job, with clean UTF-8 and flow control
&lt;/h2&gt;

&lt;p&gt;Opening a fresh SSH TCP handshake and key exchange for every small &lt;code&gt;docker inspect&lt;/code&gt; or &lt;code&gt;mkdir&lt;/code&gt; call slows down deployments and triggers &lt;code&gt;MaxStartups&lt;/code&gt; rate limits on OpenSSH.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SshExecutor&lt;/code&gt; lazily opens one SSH connection per job, reuses it across channels (&lt;code&gt;exec&lt;/code&gt;, &lt;code&gt;upload&lt;/code&gt;, &lt;code&gt;readFile&lt;/code&gt;), clears the cached promise immediately on &lt;code&gt;close&lt;/code&gt; so the next step reconnects if dropped, and pairs each stream with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;StringDecoder("utf8")&lt;/code&gt;:&lt;/strong&gt; Prevents multibyte UTF-8 log characters from splitting into replacement characters across TCP packet boundaries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explicit flow control (&lt;code&gt;onFlowControl&lt;/code&gt;):&lt;/strong&gt; Exposes &lt;code&gt;pause()&lt;/code&gt; and &lt;code&gt;resume()&lt;/code&gt; hooks to callers like streaming backups, keeping memory flat when the S3 or disk sink is slower than the VPS network interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What an SSH executor still assumes
&lt;/h2&gt;

&lt;p&gt;An executor guarantees how Nitrobase sends commands, cancels them, writes files under &lt;code&gt;/etc/nitrobase&lt;/code&gt;, and checks host keys.&lt;/p&gt;

&lt;p&gt;It does not restrict what commands are valid once authenticated as the SSH user—if an attacker compromises the control plane database and encryption key, or already holds root on the VPS, host-key pinning and &lt;code&gt;managedWriteScript&lt;/code&gt; cannot prevent deliberate misuse. Security at that layer still depends on protecting the control plane and VPS credentials.&lt;/p&gt;

&lt;h2&gt;
  
  
  My checklist for running remote commands over SSH
&lt;/h2&gt;

&lt;p&gt;Before trusting an automated SSH execution layer in production, these are the edge cases I check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are host keys verified against a stored SHA-256 fingerprint instead of accepting every key?&lt;/li&gt;
&lt;li&gt;Does job cancellation terminate grandchildren on the VPS rather than just closing the local socket?&lt;/li&gt;
&lt;li&gt;Is there a fallback timeout inside the remote host in case network connectivity drops mid-command?&lt;/li&gt;
&lt;li&gt;Are remote file paths normalized and checked with &lt;code&gt;realpath&lt;/code&gt; to prevent symlink escapes?&lt;/li&gt;
&lt;li&gt;Are remote file writes staged to a temp file and atomically swapped with &lt;code&gt;mv -T&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;Do long binary streams expose &lt;code&gt;pause()&lt;/code&gt; / &lt;code&gt;resume()&lt;/code&gt; backpressure so large backups don't OOM the server?&lt;/li&gt;
&lt;li&gt;Are UTF-8 log streams decoded with a stateful decoder across packet boundaries?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Running &lt;code&gt;conn.exec("docker compose up -d")&lt;/code&gt; works on day one. Handling timeouts, symlinks, cancellation, and MITM protection is what turns an SSH wrapper into infrastructure software.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ssh</category>
      <category>selfhosted</category>
      <category>linux</category>
    </item>
    <item>
      <title>The Hard Part of a Browser SSH Terminal Is Closing It</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Sun, 22 Nov 2026 16:05:58 +0000</pubDate>
      <link>https://dev.to/hoagminh/the-hard-part-of-a-browser-ssh-terminal-is-closing-it-1en8</link>
      <guid>https://dev.to/hoagminh/the-hard-part-of-a-browser-ssh-terminal-is-closing-it-1en8</guid>
      <description>&lt;p&gt;A browser terminal looks like a straightforward UI feature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xterm.js in browser  &amp;lt;──WebSocket──&amp;gt;  SSH PTY on VPS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most tutorials implement it in fifty lines. Upgrade a WebSocket, connect an SSH client, pipe stdin in one direction, pipe stdout in the other.&lt;/p&gt;

&lt;p&gt;The hard part is not opening the shell.&lt;/p&gt;

&lt;p&gt;The hard part is everything that happens while that WebSocket stays open:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What happens if another browser tab opens a WebSocket using the user's cookie?&lt;/li&gt;
&lt;li&gt;What happens if an administrator removes that user from the team while their bash session is still open?&lt;/li&gt;
&lt;li&gt;What happens if the user closes the tab &lt;em&gt;while&lt;/em&gt; the SSH handshake is still connecting?&lt;/li&gt;
&lt;li&gt;What happens if someone leaves an interactive root prompt idle for six hours?&lt;/li&gt;
&lt;li&gt;What happens if someone pastes 50 KB of text or sends a 10,000-column resize frame?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These questions shaped the &lt;strong&gt;WebSocket terminal handler&lt;/strong&gt; in Nitrobase.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. Providing a host or container shell from a web panel creates real operational risk, so the terminal handler is designed around explicit boundaries rather than treating the WebSocket as a thin pipe.&lt;/p&gt;

&lt;h2&gt;
  
  
  Browsers do not enforce CORS on WebSocket upgrades
&lt;/h2&gt;

&lt;p&gt;A standard cross-origin &lt;code&gt;fetch()&lt;/code&gt; is blocked by browsers unless the server opts in with CORS headers.&lt;/p&gt;

&lt;p&gt;WebSocket upgrades behave differently. Any third-party page can attempt:&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;new&lt;/span&gt; &lt;span class="nc"&gt;WebSocket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"wss://your-panel.example.com/api/servers/&amp;lt;id&amp;gt;/terminal"&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;If the user is signed in to your panel, the browser automatically attaches the session cookie to that WebSocket handshake. Without an explicit origin check, a malicious website could connect to your panel's shell endpoint on the user's behalf—an attack known as &lt;strong&gt;Cross-Site WebSocket Hijacking (CSWSH)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Nitrobase checks &lt;code&gt;Origin&lt;/code&gt; before accepting the upgrade:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebSocket upgrade request
        |
        +--&amp;gt; Origin header missing or malformed      --&amp;gt; 403 Forbidden
        |
        +--&amp;gt; Origin host != Host / X-Forwarded-Host  --&amp;gt; 403 Forbidden
        |
        +--&amp;gt; Origin host matches                     --&amp;gt; check cookie + RBAC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browsers always attach the &lt;code&gt;Origin&lt;/code&gt; header on WebSocket upgrades and client JavaScript cannot forge it, so comparing &lt;code&gt;Origin&lt;/code&gt; against the target &lt;code&gt;Host&lt;/code&gt; (or proxy-forwarded &lt;code&gt;X-Forwarded-Host&lt;/code&gt;) closes cross-site upgrades before any session lookup or SSH work runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Opening a session is an HTTP check; keeping it open is a state problem
&lt;/h2&gt;

&lt;p&gt;On normal HTTP API routes, revoking a user's session or changing their team role takes effect on the very next request.&lt;/p&gt;

&lt;p&gt;A WebSocket terminal is different. Once upgraded, it can stay connected for hours without issuing another HTTP request.&lt;/p&gt;

&lt;p&gt;Imagine a realistic team scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;14:00  User opens a host shell as a Team Operator (allowed)
14:05  Admin removes User from the team (or drops terminal permission)
14:06  Browser WebSocket is STILL connected to bash on the VPS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checking permissions only during &lt;code&gt;upgrade&lt;/code&gt; leaves that shell alive until the user voluntarily closes the tab.&lt;/p&gt;

&lt;p&gt;Nitrobase registers every open terminal socket (and live SSE stream) with an in-process live connection registry (&lt;code&gt;trackLiveConnection&lt;/code&gt;). Each tracked entry records the &lt;code&gt;sessionId&lt;/code&gt;, &lt;code&gt;userId&lt;/code&gt;, active &lt;code&gt;teamId&lt;/code&gt;, and required permission (&lt;code&gt;server.terminal&lt;/code&gt; for host shells, &lt;code&gt;app.terminal&lt;/code&gt; for container shells):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Immediate revocation hooks:&lt;/strong&gt; Signing out or revoking a session notifies matching live connections immediately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Periodic re-validation backstop:&lt;/strong&gt; Every 30 seconds, the registry validates active sessions and team permissions in bulk against the database.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When a session expires or the member loses the &lt;code&gt;server.terminal&lt;/code&gt; or &lt;code&gt;app.terminal&lt;/code&gt; permission, Nitrobase writes a localized banner directly into the terminal stream, tears down the remote PTY/executor, and closes the WebSocket with custom close codes (&lt;code&gt;4403&lt;/code&gt; for team access changed, &lt;code&gt;4401&lt;/code&gt; for session ended).&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing a tab mid-handshake leaks remote shells
&lt;/h2&gt;

&lt;p&gt;Connecting to a remote VPS over SSH takes time—network latency, key authentication, and spawning a PTY on the server all happen asynchronously after the WebSocket &lt;code&gt;open&lt;/code&gt; event fires.&lt;/p&gt;

&lt;p&gt;If the user refreshes the page or closes the browser tab 200 milliseconds after clicking "Terminal," the WebSocket &lt;code&gt;close&lt;/code&gt; event fires &lt;em&gt;before&lt;/em&gt; &lt;code&gt;executor.shell()&lt;/code&gt; finishes resolving:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;t=0ms    WS open -&amp;gt; start async SSH connect + PTY spawn
t=150ms  User closes tab -&amp;gt; WS close fires (session doesn't exist yet!)
t=400ms  SSH connect finishes -&amp;gt; PTY spawns -&amp;gt; nobody is listening!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without explicit tracking, that orphaned &lt;code&gt;bash&lt;/code&gt; or &lt;code&gt;docker exec -it&lt;/code&gt; process sits open on the managed server indefinitely.&lt;/p&gt;

&lt;p&gt;Nitrobase sets a &lt;code&gt;closed&lt;/code&gt; flag on the connection state when &lt;code&gt;close&lt;/code&gt; fires and checks it at two checkpoints inside the async setup path:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;right after &lt;code&gt;getExecutor(target.server)&lt;/code&gt; resolves;&lt;/li&gt;
&lt;li&gt;right after &lt;code&gt;executor.shell(...)&lt;/code&gt; resolves.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If &lt;code&gt;state.closed&lt;/code&gt; became &lt;code&gt;true&lt;/code&gt; while awaiting either step, &lt;code&gt;teardown()&lt;/code&gt; immediately closes both the shell session and the underlying SSH executor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Input frames, pastes, and resize dimensions are untrusted
&lt;/h2&gt;

&lt;p&gt;Even an authenticated terminal user should not be able to crash a PTY process or hang the server with malformed WebSocket frames.&lt;/p&gt;

&lt;p&gt;Nitrobase validates and bounds every frame in &lt;code&gt;parseTerminalMessage()&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Control&lt;/th&gt;
&lt;th&gt;Limit / Behavior&lt;/th&gt;
&lt;th&gt;Why it exists&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Per-frame input cap&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;4 KiB&lt;/code&gt; (&lt;code&gt;4096&lt;/code&gt; UTF-16 code units)&lt;/td&gt;
&lt;td&gt;Oversized frames are dropped whole with a terminal notice rather than buffered infinitely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client paste chunking&lt;/td&gt;
&lt;td&gt;&lt;code&gt;chunkTerminalInput()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Splits large pastes into ordered frames under &lt;code&gt;4 KiB&lt;/code&gt;, preserving UTF-16 surrogate pairs and accounting for JSON escape expansion (up to 6x for control chars)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Terminal resize bounds&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;cols&lt;/code&gt;: &lt;code&gt;10..500&lt;/code&gt;, &lt;code&gt;rows&lt;/code&gt;: &lt;code&gt;5..200&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Prevents negative, &lt;code&gt;NaN&lt;/code&gt;, or giant resize payloads from reaching the PTY&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Idle timeout&lt;/td&gt;
&lt;td&gt;&lt;code&gt;TERMINAL_IDLE_TIMEOUT_MS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Closes unattended shells; reset by real input frames, never by background resize events&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Notice that last distinction: browser windows resize when a laptop docks or splits screen. Resetting the idle timer on &lt;code&gt;resize&lt;/code&gt; frames could keep an abandoned terminal open accidentally, so only interactive input resets it.&lt;/p&gt;

&lt;p&gt;Also, if a user starts typing commands while the SSH session is still connecting (&lt;code&gt;t=100ms&lt;/code&gt;), &lt;code&gt;message&lt;/code&gt; awaits &lt;code&gt;state.ready&lt;/code&gt; so those initial keystrokes are queued cleanly and delivered once the PTY is ready—or discarded if the connection failed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Container shells vs. host shells are separate permissions
&lt;/h2&gt;

&lt;p&gt;Not every teammate who needs to inspect an application container should get a login shell on the underlying VPS host.&lt;/p&gt;

&lt;p&gt;Nitrobase splits terminal access into two endpoints and two distinct RBAC permissions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;/api/servers/:serverId/terminal&lt;/code&gt; (&lt;code&gt;server.terminal&lt;/code&gt;):&lt;/strong&gt; Opens a host shell on the managed VPS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;/api/apps/:appId/terminal?service=...&lt;/code&gt; (&lt;code&gt;app.terminal&lt;/code&gt;):&lt;/strong&gt; Runs a trusted &lt;code&gt;docker exec -it&lt;/code&gt; command directly inside a specific service container rather than dropping the user onto the VPS root prompt.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both endpoints share the exact same &lt;code&gt;createTerminalHandler()&lt;/code&gt; boundary, origin checks, live revocation tracking, idle timer, and audit trail. Every session records both an open audit event and a close audit event containing the end reason (&lt;code&gt;closed&lt;/code&gt;, &lt;code&gt;TERMINAL_IDLE&lt;/code&gt;, &lt;code&gt;TERMINAL_ACCESS_CHANGED&lt;/code&gt;, or &lt;code&gt;TERMINAL_SESSION_ENDED&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  What a browser terminal still does not protect against
&lt;/h2&gt;

&lt;p&gt;A terminal guard controls &lt;em&gt;who&lt;/em&gt; can open and keep a shell over HTTP/WebSocket.&lt;/p&gt;

&lt;p&gt;Once an authorized operator has an active host shell or container shell, they hold whatever privileges the underlying SSH user or container user possesses. Origin checks and live revocation do not restrict what commands an authorized user runs inside their session, nor do they replace least-privilege container users or host-level SSH key management.&lt;/p&gt;

&lt;h2&gt;
  
  
  My WebSocket terminal checklist
&lt;/h2&gt;

&lt;p&gt;Before shipping an interactive shell in a web control plane, these are the boundaries I verify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Does the WebSocket upgrade validate &lt;code&gt;Origin&lt;/code&gt; against &lt;code&gt;Host&lt;/code&gt; / &lt;code&gt;X-Forwarded-Host&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;[ ] Are permissions verified both at &lt;code&gt;upgrade&lt;/code&gt; and again inside &lt;code&gt;open&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;[ ] Does revoking a session or changing a team role immediately terminate already-open terminals?&lt;/li&gt;
&lt;li&gt;[ ] Does disconnecting while SSH is still connecting clean up the newly spawned PTY instead of leaking it?&lt;/li&gt;
&lt;li&gt;[ ] Are client-supplied &lt;code&gt;rows&lt;/code&gt; and &lt;code&gt;cols&lt;/code&gt; clamped to sensible integer bounds?&lt;/li&gt;
&lt;li&gt;[ ] Are WebSocket input frames size-bounded, with large pastes chunked safely on the client?&lt;/li&gt;
&lt;li&gt;[ ] Are idle shells closed automatically, without letting &lt;code&gt;resize&lt;/code&gt; events keep them alive?&lt;/li&gt;
&lt;li&gt;[ ] Are both terminal start and terminal close (with reason) written to the audit log?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Connecting &lt;code&gt;xterm.js&lt;/code&gt; to an SSH stream gets you a working demo in an afternoon. Building the teardown and revocation path around it is what makes it safe to leave in production.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>selfhosted</category>
      <category>devops</category>
      <category>websockets</category>
    </item>
    <item>
      <title>Why fetch(webhookUrl) Is a Trap: SSRF and DNS Rebinding in a Self-Hosted PaaS</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Sat, 21 Nov 2026 14:50:11 +0000</pubDate>
      <link>https://dev.to/hoagminh/why-fetchwebhookurl-is-a-trap-ssrf-and-dns-rebinding-in-a-self-hosted-paas-2jdn</link>
      <guid>https://dev.to/hoagminh/why-fetchwebhookurl-is-a-trap-ssrf-and-dns-rebinding-in-a-self-hosted-paas-2jdn</guid>
      <description>&lt;p&gt;Sooner or later, a self-hosted control plane has to make outbound requests to URLs provided by its users.&lt;/p&gt;

&lt;p&gt;A team configures a Discord or custom webhook for alerts. Someone enters an S3-compatible endpoint for nightly backups. Another user pastes a Git repository URL or connects a cloud sync target.&lt;/p&gt;

&lt;p&gt;The naive implementation fits on one line:&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="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="n"&gt;userProvidedUrl&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="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&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;The problem is where that request runs.&lt;/p&gt;

&lt;p&gt;It runs inside the management panel—on a machine that often has access to &lt;code&gt;127.0.0.1&lt;/code&gt;, internal Docker networks, private VPN interfaces, local databases, or cloud provider metadata endpoints at &lt;code&gt;169.254.169.254&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If a user supplies a URL and the panel blindly calls &lt;code&gt;fetch()&lt;/code&gt;, that user may be able to turn the control plane into a proxy into the server's private network.&lt;/p&gt;

&lt;p&gt;This is the problem behind &lt;strong&gt;outbound SSRF guards and pinned HTTP&lt;/strong&gt; in Nitrobase.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. These guards do not eliminate every risk of running third-party workloads on a VPS. Their narrower job is to keep user-supplied outbound URLs from quietly reaching internal addresses unless private-network access is explicitly enabled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why string checks and &lt;code&gt;startsWith("127.")&lt;/code&gt; break immediately
&lt;/h2&gt;

&lt;p&gt;The first instinct when guarding URLs is usually a quick string check:&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="c1"&gt;// Fragile: misses mapped, encoded, and alternate IP representations&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;host&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"localhost"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"127."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"192.168."&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;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;"blocked"&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;Text matching misses how operating systems and network stacks actually parse IP addresses.&lt;/p&gt;

&lt;p&gt;Consider how many ways an address can still reach loopback or link-local metadata:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;localhost.&lt;/code&gt; with a trailing dot, or &lt;code&gt;sub.localhost&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;IPv4-mapped IPv6 such as &lt;code&gt;[::ffff:127.0.0.1]&lt;/code&gt; or &lt;code&gt;[::ffff:169.254.169.254]&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;SIIT translation addresses like &lt;code&gt;[::ffff:0:127.0.0.1]&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;IPv4-compatible IPv6 notation (&lt;code&gt;[::127.0.0.1]&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;NAT64 (&lt;code&gt;64:ff9b::/96&lt;/code&gt;) and 6to4 (&lt;code&gt;2002::/16&lt;/code&gt;) encodings with embedded IPv4 bits;&lt;/li&gt;
&lt;li&gt;CGNAT space (&lt;code&gt;100.64.0.0/10&lt;/code&gt;), &lt;code&gt;0.0.0.0/8&lt;/code&gt; ("this network"), and IPv6 unique-local (&lt;code&gt;fc00::/7&lt;/code&gt;) or link-local (&lt;code&gt;fe80::/10&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of matching text patterns, Nitrobase parses IPv4 strings into four bytes and expands IPv6 strings—including &lt;code&gt;::&lt;/code&gt; compression, embedded IPv4 tails, and &lt;code&gt;%zone&lt;/code&gt; IDs—into eight 16-bit hextets. Any embedded IPv4 address inside a transition format is extracted and evaluated against the blocked IPv4 CIDR ranges too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User hostname string
        |
        v
Normalize brackets, trailing dot, zone ID
        |
        +--&amp;gt; Parse IPv4 bytes -----&amp;gt; check private/CGNAT/metadata CIDRs
        |
        +--&amp;gt; Parse IPv6 hextets ---&amp;gt; unwrap mapped/NAT64/6to4 IPv4 ---&amp;gt; check CIDRs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Parsing addresses rather than regexing strings closes an entire class of trivial bypasses before any DNS query even happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking the URL at save time is not enough
&lt;/h2&gt;

&lt;p&gt;Even when every literal IP range is covered, a hostname introduces a timing gap:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Time 0 (Save webhook):    evil.example.com  ──DNS──►  93.184.216.34 (public: allowed)

Time 1 (Send alert):      evil.example.com  ──DNS──►  127.0.0.1     (private: danger!)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is &lt;strong&gt;DNS rebinding&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;An attacker controls the domain's authoritative nameserver with a short TTL. When Nitrobase validates the webhook or S3 endpoint during configuration save, DNS returns a normal public IP. Later, when a backup job or notification fires, DNS returns &lt;code&gt;127.0.0.1&lt;/code&gt; or &lt;code&gt;169.254.169.254&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A similar trap happens with rotating DNS records: a single domain configured with two A records—one public, one internal. If validation checks only &lt;code&gt;addresses[0]&lt;/code&gt;, the connection phase might pick &lt;code&gt;addresses[1]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Nitrobase handles this in two stages:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;What it checks&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Save time&lt;/td&gt;
&lt;td&gt;Fast feedback in the UI&lt;/td&gt;
&lt;td&gt;Rejects private literals, unresolved hosts, and any DNS answer containing a private IP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Send / connect time&lt;/td&gt;
&lt;td&gt;Prevents TOCTOU &amp;amp; rebinding&lt;/td&gt;
&lt;td&gt;Resolves fresh, rejects if &lt;em&gt;any&lt;/em&gt; address is private, and pins the connection to one checked IP&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;An endpoint that returns a mix of public and private DNS records is rejected entirely when private networking is off.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pinning the socket—and why runtimes complicate it
&lt;/h2&gt;

&lt;p&gt;Resolving a hostname once in application code does not automatically stop the HTTP client from resolving it a second time when opening the TCP socket.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Naive check-then-fetch:
  1. dns.lookup(host)  -&amp;gt; 93.184.216.34 (ok!)
  2. fetch(url)        -&amp;gt; OS calls dns.lookup(host) AGAIN -&amp;gt; 127.0.0.1 (rebound!)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nitrobase's outbound HTTP client avoids &lt;code&gt;fetch()&lt;/code&gt; for user-influenced hosts and instead uses &lt;code&gt;node:http&lt;/code&gt; / &lt;code&gt;node:https&lt;/code&gt; with three strict settings:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Custom &lt;code&gt;lookup&lt;/code&gt; callback (&lt;code&gt;pinnedLookup&lt;/code&gt;):&lt;/strong&gt; Forces the socket to connect strictly to the single pre-verified IP address instead of querying DNS again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No connection pooling (&lt;code&gt;agent: false&lt;/code&gt;):&lt;/strong&gt; Ensures a fresh socket check per request so stale pooled connections cannot linger across configuration changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Socket peer verification on &lt;code&gt;connect&lt;/code&gt;:&lt;/strong&gt; Inspects &lt;code&gt;socket.remoteAddress&lt;/code&gt; as soon as the TCP connection establishes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That third check exists because of a subtle cross-runtime reality: alternative JavaScript runtimes (such as Bun's Node compatibility layer) do not always honor a custom &lt;code&gt;lookup&lt;/code&gt; option the same way Node does—some runtimes still perform their own resolution internally.&lt;/p&gt;

&lt;p&gt;Verifying the actual connected &lt;code&gt;socket.remoteAddress&lt;/code&gt; catches a rebind even if the underlying socket layer bypassed &lt;code&gt;pinnedLookup&lt;/code&gt;, tearing down the socket immediately before HTTP data is exchanged:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resolvePinned(host) -&amp;gt; 93.184.216.34 (verified public)
        |
        v
http.request(..., { lookup: pinnedLookup, agent: false })
        |
        v
on socket connect -&amp;gt; check socket.remoteAddress
        |
        +-- matches public IP  --&amp;gt; send request
        +-- private / empty    --&amp;gt; request.destroy("blocked")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Redirects and plain HTTP are part of the same boundary
&lt;/h2&gt;

&lt;p&gt;Stopping DNS rebinding at the first hop does little good if the remote server can reply with a redirect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;302&lt;/span&gt; &lt;span class="nc"&gt;Found&lt;/span&gt;
&lt;span class="nc"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//169.254.169.254/latest/meta-data/iam/security-credentials/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Standard HTTP clients like &lt;code&gt;fetch()&lt;/code&gt; follow redirects automatically by default (&lt;code&gt;redirect: "follow"&lt;/code&gt;). Each hop silently exits your SSRF validation unless every redirect target is re-validated through the same pipeline.&lt;/p&gt;

&lt;p&gt;Nitrobase treats redirects on guarded outbound requests as explicit failures rather than hops to chase:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No auto-redirects:&lt;/strong&gt; Using &lt;code&gt;http.request&lt;/code&gt; / &lt;code&gt;https.request&lt;/code&gt; means &lt;code&gt;3xx&lt;/code&gt; responses are returned directly and classified as a non-retryable redirect rejection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTPS by default:&lt;/strong&gt; Plain &lt;code&gt;http://&lt;/code&gt; URLs are blocked unless the user has explicitly enabled the &lt;strong&gt;private network&lt;/strong&gt; option for an internal self-hosted endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capped response reading:&lt;/strong&gt; Even a valid remote server can attempt to exhaust panel memory by streaming gigabytes back. Nitrobase bounds response reads (&lt;code&gt;maxResponseBytes&lt;/code&gt;)—either truncating diagnostic bodies at 64 KiB for webhooks or aborting oversized cloud-sync downloads cleanly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where Nitrobase applies this boundary
&lt;/h2&gt;

&lt;p&gt;SSRF protection only works if every user-supplied outbound surface uses it consistently, not just webhooks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Notification webhooks &amp;amp; chat channels:&lt;/strong&gt; Discord, Slack, Telegram, custom signed webhooks, and SMTP hosts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backup destinations &amp;amp; cloud sync:&lt;/strong&gt; Custom S3-compatible endpoints, Cloudflare R2, Backblaze B2, and Appwrite/external sync providers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git repository clones:&lt;/strong&gt; Even Git URLs resolve the host first via &lt;code&gt;resolveGitHost()&lt;/code&gt;, refusing hostnames that mix public and private records and rejecting non-standard credential smuggling in repository URLs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the same time, a self-hosted PaaS often genuinely needs to talk to an internal MinIO instance on a private VLAN or a local Gitea server over VPN.&lt;/p&gt;

&lt;p&gt;That is why Nitrobase makes &lt;code&gt;allowPrivate&lt;/code&gt; an explicit, per-destination setting rather than disabling checks globally. Public endpoints stay guarded; intentional internal endpoints are clearly marked as private-network connections.&lt;/p&gt;

&lt;h2&gt;
  
  
  What SSRF guards still do not protect against
&lt;/h2&gt;

&lt;p&gt;An outbound HTTP guard narrows what a panel user can make the control plane fetch. It is not a full egress firewall.&lt;/p&gt;

&lt;p&gt;It does not restrict what arbitrary application containers deployed on a managed VPS request from inside their own Docker networks, nor does it make an untrusted webhook endpoint safe if an administrator purposefully enables private-network mode on it. Network segmentation on the host remains the real outer perimeter.&lt;/p&gt;

&lt;h2&gt;
  
  
  My outbound URL checklist
&lt;/h2&gt;

&lt;p&gt;Before calling an external URL from a control plane or API backend, these are the checks I want to answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Are IPv4-mapped IPv6, NAT64, 6to4, and CGNAT ranges parsed numerically rather than regexed?&lt;/li&gt;
&lt;li&gt;[ ] Does validation reject hostnames whose DNS answers mix public and private IPs?&lt;/li&gt;
&lt;li&gt;[ ] Is the resolved IP pinned at connect time instead of performing a second DNS lookup inside &lt;code&gt;fetch()&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;[ ] Does the socket &lt;code&gt;connect&lt;/code&gt; listener re-verify &lt;code&gt;socket.remoteAddress&lt;/code&gt; against private ranges?&lt;/li&gt;
&lt;li&gt;[ ] Are HTTP &lt;code&gt;3xx&lt;/code&gt; redirects blocked instead of silently followed?&lt;/li&gt;
&lt;li&gt;[ ] Is plain &lt;code&gt;http://&lt;/code&gt; refused for public endpoints?&lt;/li&gt;
&lt;li&gt;[ ] Is the response body capped in bytes alongside a strict request timeout?&lt;/li&gt;
&lt;li&gt;[ ] Is private-network access opt-in per configuration instead of an invisible fallback?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single &lt;code&gt;fetch(url)&lt;/code&gt; hides every single one of those decisions behind convenience. Replacing it with a pinned client turns an implicit network risk into explicit infrastructure code.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>webdev</category>
      <category>security</category>
      <category>selfhosted</category>
    </item>
    <item>
      <title>What Happens When Two Deployment Panels Think They Own the Same VPS?</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Fri, 20 Nov 2026 14:14:53 +0000</pubDate>
      <link>https://dev.to/hoagminh/what-happens-when-two-deployment-panels-think-they-own-the-same-vps-b9c</link>
      <guid>https://dev.to/hoagminh/what-happens-when-two-deployment-panels-think-they-own-the-same-vps-b9c</guid>
      <description>&lt;p&gt;Connecting a deployment panel to a VPS is easy.&lt;/p&gt;

&lt;p&gt;Give it an address, an SSH key, and permission to install Docker. A few minutes later, the panel can deploy applications, configure Traefik, create networks, and manage volumes.&lt;/p&gt;

&lt;p&gt;The uncomfortable question comes later:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What happens when a second panel connects to the same server and believes the same infrastructure belongs to it?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is not a normal multi-user conflict. Both panels may have root access. Both may believe their database contains the desired state. Both may be capable of “repairing” the server until it matches that state.&lt;/p&gt;

&lt;p&gt;One panel updates Traefik. The other changes it back. One removes a container it cannot find in its database. The other recreates it. A cleanup screen sees an unfamiliar volume and offers to delete it.&lt;/p&gt;

&lt;p&gt;The individual commands may be correct. The ownership assumption is not.&lt;/p&gt;

&lt;p&gt;This problem shaped the server-ownership mechanism in &lt;strong&gt;Nitrobase&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. The goal of this feature is small but important: before changing a managed VPS, establish which Nitrobase instance is allowed to act there—and refuse when the answer points somewhere else.&lt;/p&gt;

&lt;h2&gt;
  
  
  The dangerous version of “desired state”
&lt;/h2&gt;

&lt;p&gt;A deployment panel normally works from two views of the world:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Panel database                 Actual VPS
--------------                 ----------
App A should run        &amp;lt;--&amp;gt;   containers
domain.example.com      &amp;lt;--&amp;gt;   Traefik routes
database volume exists  &amp;lt;--&amp;gt;   Docker volumes
backup runs nightly     &amp;lt;--&amp;gt;   files and schedules
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The panel compares them and performs work to bring the server toward its desired state.&lt;/p&gt;

&lt;p&gt;That model works while one control plane is authoritative.&lt;/p&gt;

&lt;p&gt;Now add another panel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Panel Alpha ---------\
                      &amp;gt;---- Same VPS
Panel Beta ----------/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alpha does not know what Beta deployed. Beta does not know which resources Alpha still needs. Absence from one database does not mean a resource is abandoned.&lt;/p&gt;

&lt;p&gt;This creates a rule I now consider fundamental:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“I do not recognize this resource” is not evidence that I may delete it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  An SSH connection does not prove ownership
&lt;/h2&gt;

&lt;p&gt;Successfully connecting as root proves capability, not authority.&lt;/p&gt;

&lt;p&gt;An SSH key tells Nitrobase that it &lt;em&gt;can&lt;/em&gt; execute commands. It does not tell Nitrobase whether another installation already manages the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SSH authentication answers:  “May I enter this machine?”

Ownership answers:           “May this panel manage these resources?”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those are separate questions, so Nitrobase needs a separate identity.&lt;/p&gt;

&lt;p&gt;Each panel installation has an instance ID. Resources created or adopted by that panel carry the ID in several places on the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ownership needs more than one marker
&lt;/h2&gt;

&lt;p&gt;A single marker is fragile because infrastructure has several lifecycles.&lt;/p&gt;

&lt;p&gt;A container can be recreated. An application folder can remain after its containers are removed. Traefik can exist while the panel database is temporarily unavailable. Older installations may contain resources created before ownership tracking existed.&lt;/p&gt;

&lt;p&gt;Nitrobase records ownership at three levels:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Resource&lt;/th&gt;
&lt;th&gt;Ownership record&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Managed server root&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;instance-id&lt;/code&gt; marker file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traefik and app containers&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;nitrobase.instance&lt;/code&gt; Docker label&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application folder&lt;/td&gt;
&lt;td&gt;Reserved &lt;code&gt;.nitrobase-instance&lt;/code&gt; marker&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The result is not a perfect distributed consensus system. It is a set of durable signals placed beside the things the panel may later modify or delete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/etc/nitrobase/
├── instance-id                 -&amp;gt; panel instance
└── apps/
    └── my-app-ab12cd34/
        ├── .nitrobase-instance -&amp;gt; app-folder owner
        ├── compose.yml
        └── data/

Docker container labels:
nitrobase.instance=&amp;lt;instance-id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The marker filenames are reserved so an application template cannot casually replace or mount over them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The check happens before the change
&lt;/h2&gt;

&lt;p&gt;An ownership warning shown after a bootstrap has already rewritten proxy configuration would be too late.&lt;/p&gt;

&lt;p&gt;Before Nitrobase bootstraps a server, it probes the managed-root marker and the Traefik ownership label. If either contains another instance ID, the operation is refused before the first server-changing step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connect to VPS
     |
Read root marker + Traefik label
     |
     +-- no foreign owner --&amp;gt; continue
     |
     +-- foreign owner ----&amp;gt; refuse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same ownership boundary is used for later operations that can alter the server, including deployment and routing work.&lt;/p&gt;

&lt;p&gt;That detail matters because ownership is not something to check only when a server is first added. A server can be restored from a snapshot, moved between environments, or connected to another panel after its initial bootstrap.&lt;/p&gt;

&lt;p&gt;The server remains the source of evidence for who currently claims its Nitrobase-managed root.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the refusal looks like
&lt;/h2&gt;

&lt;p&gt;Suppose Panel Alpha has instance ID &lt;code&gt;alpha-01&lt;/code&gt; and has already bootstrapped a VPS.&lt;/p&gt;

&lt;p&gt;Panel Beta connects using a perfectly valid root SSH key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Panel Beta expects:  beta-07
Server marker says:  alpha-01

Result: deployment refused
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nitrobase reports that another instance manages the server instead of attempting to merge two control-plane states.&lt;/p&gt;

&lt;p&gt;This can feel inconvenient during a migration, but silent coexistence would be worse. If both panels can independently update the reverse proxy, routes, networks, and application folders, there is no reliable definition of “current.”&lt;/p&gt;

&lt;p&gt;Refusal turns an ambiguous infrastructure state into an explicit administrative decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeover should not be an accidental side effect
&lt;/h2&gt;

&lt;p&gt;There are legitimate reasons to move authority:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the old panel was lost;&lt;/li&gt;
&lt;li&gt;its database was restored into a fresh installation;&lt;/li&gt;
&lt;li&gt;a staging panel is being promoted;&lt;/li&gt;
&lt;li&gt;an administrator intentionally replaces one control plane with another.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But “I have the SSH key” is still not enough evidence to perform a takeover automatically.&lt;/p&gt;

&lt;p&gt;The safe sequence is closer to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Stop the old panel permanently
2. Recover or verify its desired state
3. Confirm which applications exist on the VPS
4. Explicitly transfer ownership
5. Let the new panel converge the server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nitrobase supports an explicit takeover path during bootstrap. It is a deliberate exception to the normal refusal, not a fallback triggered merely because the new panel cannot understand the old marker.&lt;/p&gt;

&lt;p&gt;The distinction protects against a common operational mistake: using a fresh panel to “inspect” an existing server and accidentally converting inspection into control.&lt;/p&gt;

&lt;h2&gt;
  
  
  App resources need their own identity too
&lt;/h2&gt;

&lt;p&gt;The server-level marker answers who manages the Nitrobase root and Traefik. Cleanup needs a more specific answer: who created this application folder and its containers?&lt;/p&gt;

&lt;p&gt;Nitrobase adds the instance label to containers through the Compose transformation it already applies during deployment. It also writes the instance marker into the top of each application folder.&lt;/p&gt;

&lt;p&gt;This lets an orphan scan classify resources into three groups:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Classification&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Automatic wipe allowed?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;self&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Owned by this panel instance&lt;/td&gt;
&lt;td&gt;Only with other safety checks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;foreign&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Another instance ID is present&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;unknown&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No valid owner is recorded&lt;/td&gt;
&lt;td&gt;No by default&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;unknown&lt;/code&gt; category is especially important.&lt;/p&gt;

&lt;p&gt;Unknown may mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the app was created before ownership markers existed;&lt;/li&gt;
&lt;li&gt;the folder was copied manually;&lt;/li&gt;
&lt;li&gt;a marker was removed;&lt;/li&gt;
&lt;li&gt;another tool created similar resources;&lt;/li&gt;
&lt;li&gt;the current panel has incomplete evidence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of those meanings imply “safe to delete.”&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Known to be mine      -&amp;gt; potentially manageable
Known to be foreign   -&amp;gt; leave it alone
Unknown               -&amp;gt; also leave it alone
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Uncertainty is treated as a reason to preserve data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why volumes inherit ownership from the project
&lt;/h2&gt;

&lt;p&gt;It might seem simpler to place an instance label directly on every Docker volume.&lt;/p&gt;

&lt;p&gt;Nitrobase deliberately avoids relying on that.&lt;/p&gt;

&lt;p&gt;Docker volume labels are effectively immutable in the lifecycle that Compose expects. Changing them can lead Compose to request recreation of the volume—the exact behavior an ownership migration must avoid when the volume contains application data.&lt;/p&gt;

&lt;p&gt;Instead, a named volume is associated with its Compose project, and the project ownership is derived from the application folder and labelled containers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App folder marker ----\
                       &amp;gt;---- Compose project ---- named volumes
Container labels -----/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is less visually direct than labelling every object, but it avoids turning metadata repair into a data-loss operation.&lt;/p&gt;

&lt;p&gt;The safest ownership system is not the one with the most labels. It is the one that does not destroy data while trying to improve its labels.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cleanup is where ownership becomes real
&lt;/h2&gt;

&lt;p&gt;Ownership metadata is easy to describe when deploying. Its value becomes visible when deleting.&lt;/p&gt;

&lt;p&gt;Nitrobase's orphan view can find application folders, labelled containers, and volumes that no longer correspond to an app in the current panel database.&lt;/p&gt;

&lt;p&gt;But it does not equate “not in my database” with “mine to wipe.”&lt;/p&gt;

&lt;p&gt;Before removing an orphan, Nitrobase checks again:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;the resource is still absent from the panel's known applications;&lt;/li&gt;
&lt;li&gt;its owner classification is allowed;&lt;/li&gt;
&lt;li&gt;no container in that project is currently running;&lt;/li&gt;
&lt;li&gt;the administrator typed the required confirmation;&lt;/li&gt;
&lt;li&gt;the state has not changed between the preview and the actual job.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Foreign resources are refused.&lt;/p&gt;

&lt;p&gt;Resources with no recorded owner require a stronger, instance-administrator-only path and an explicit phrase. The interface warns that they may belong to another panel or predate ownership markers.&lt;/p&gt;

&lt;p&gt;Even then, this is a human risk decision—not proof manufactured by the software.&lt;/p&gt;

&lt;h2&gt;
  
  
  Labels are not a security boundary against root
&lt;/h2&gt;

&lt;p&gt;It is important not to oversell this mechanism.&lt;/p&gt;

&lt;p&gt;An administrator with root access can edit marker files, recreate containers, or change Docker labels. A malicious second panel with unrestricted root access could ignore every ownership signal.&lt;/p&gt;

&lt;p&gt;The mechanism is designed to prevent accidental control-plane conflict and unsafe cleanup between cooperative Nitrobase installations.&lt;/p&gt;

&lt;p&gt;It does not defend a server from an attacker who already controls the host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Protects against:
  ✓ accidental double management
  ✓ mistaken cleanup by another Nitrobase panel
  ✓ treating unknown resources as disposable

Does not protect against:
  ✗ malicious root access
  ✗ manual deletion outside Nitrobase
  ✗ forged or edited ownership markers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The security boundary remains the VPS and its root credentials. Ownership markers add operational safety inside that boundary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recovery and ownership are connected
&lt;/h2&gt;

&lt;p&gt;This feature also explains why restoring a control plane is more than importing a database.&lt;/p&gt;

&lt;p&gt;The restored panel must know whether it is the continuation of the old instance or a new authority trying to take over. If two copies of the same panel become active, both may have the same desired state and credentials.&lt;/p&gt;

&lt;p&gt;That creates a split-brain problem even when their database contents initially match.&lt;/p&gt;

&lt;p&gt;The recovery process should therefore include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;old panel stopped
        +
restored control-plane state
        +
verified instance identity
        +
explicit resume on the new machine
        =
one active authority
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server ownership is one layer of that process. It prevents an unrelated fresh instance from quietly claiming the same infrastructure, while recovery controls prevent two copies of the same instance from acting simultaneously.&lt;/p&gt;

&lt;h2&gt;
  
  
  My checklist before connecting an existing VPS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Is another Nitrobase panel still running?&lt;/li&gt;
&lt;li&gt;[ ] Does the server already contain &lt;code&gt;/etc/nitrobase&lt;/code&gt; data?&lt;/li&gt;
&lt;li&gt;[ ] Who created the current Traefik container?&lt;/li&gt;
&lt;li&gt;[ ] Are the application folders represented in the panel database?&lt;/li&gt;
&lt;li&gt;[ ] Am I restoring the old panel or creating a genuinely new one?&lt;/li&gt;
&lt;li&gt;[ ] Have I stopped the old control plane before a takeover?&lt;/li&gt;
&lt;li&gt;[ ] Are off-site backups available before changing ownership?&lt;/li&gt;
&lt;li&gt;[ ] Do any resources have an unknown owner?&lt;/li&gt;
&lt;li&gt;[ ] Have I verified unknown volumes before considering cleanup?&lt;/li&gt;
&lt;li&gt;[ ] Is this an inspection task or an authorization to manage?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That final question is easy to overlook. Connecting to a machine should not automatically mean adopting everything on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem this feature is trying to solve
&lt;/h2&gt;

&lt;p&gt;Self-hosting gives users control over their servers and data. A management panel should reduce repetitive operations without quietly assuming that every object visible through SSH belongs to it.&lt;/p&gt;

&lt;p&gt;Nitrobase's ownership markers try to make that assumption explicit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Panel identity
      |
      +-- marks server root
      +-- labels containers
      +-- marks app folders
      |
      v
future operations can ask:
“Is this actually mine to change?”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are more edge cases to test during Beta—older installations, partially completed takeovers, manually copied application folders, server snapshots, and recovery from lost control-plane state.&lt;/p&gt;

&lt;p&gt;But the principle I want to preserve is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Infrastructure access is not infrastructure ownership, and uncertainty is not permission to delete.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sometimes the safest deployment feature is the one that refuses to deploy.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>selfhosted</category>
      <category>devops</category>
      <category>docker</category>
      <category>security</category>
    </item>
    <item>
      <title>Cron Was the Easy Part: Running Scheduled Tasks Safely Inside Containers</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Thu, 19 Nov 2026 10:23:42 +0000</pubDate>
      <link>https://dev.to/hoagminh/cron-was-the-easy-part-running-scheduled-tasks-safely-inside-containers-5dk</link>
      <guid>https://dev.to/hoagminh/cron-was-the-easy-part-running-scheduled-tasks-safely-inside-containers-5dk</guid>
      <description>&lt;p&gt;I wanted to add scheduled tasks to Nitrobase because almost every real application eventually needs one.&lt;/p&gt;

&lt;p&gt;A Laravel app clears old sessions. A Node.js service sends a digest. A database-backed product generates invoices. A small internal tool imports a CSV every night.&lt;/p&gt;

&lt;p&gt;At first, the feature sounded almost trivial:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cron expression + command = scheduled task
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I started asking what should happen when the command fires during a deployment, runs forever, fills memory, prints a password, or targets a container that is no longer running.&lt;/p&gt;

&lt;p&gt;The cron parser was the easy part.&lt;/p&gt;

&lt;p&gt;The real feature was deciding how scheduled work should behave around the rest of the application.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. The scheduled-task feature is meant to solve one practical problem: run recurring application commands from the same place that already knows where the app lives, which service should execute them, and whether that app is currently safe to touch.&lt;/p&gt;

&lt;h2&gt;
  
  
  The traditional cron entry loses context
&lt;/h2&gt;

&lt;p&gt;On a single VPS, I can always SSH in and write something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 3 * * * docker exec my-app php artisan reports:daily
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works, but the line quietly depends on knowledge stored in my head:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the correct server;&lt;/li&gt;
&lt;li&gt;the current container name;&lt;/li&gt;
&lt;li&gt;the service that contains the command;&lt;/li&gt;
&lt;li&gt;the deployment schedule;&lt;/li&gt;
&lt;li&gt;the maximum acceptable runtime;&lt;/li&gt;
&lt;li&gt;where stdout and stderr should go;&lt;/li&gt;
&lt;li&gt;who should be notified when it fails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Six months later, the application may have moved to another VPS while the old cron entry remains behind. The container may have been renamed. A teammate may redeploy the app at 03:00 without knowing a report job is halfway through.&lt;/p&gt;

&lt;p&gt;The command is automated, but its operational context is not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System cron knows:       "run this text at 03:00"

Nitrobase also knows:    which app
                         which server
                         which service
                         whether the app is running
                         whether deploy or backup is active
                         who may inspect the output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That extra context is where a control plane can be useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  A task runs inside the service, never on the host
&lt;/h2&gt;

&lt;p&gt;The first boundary I wanted was simple: an application task should not become a disguised root command on the VPS.&lt;/p&gt;

&lt;p&gt;Nitrobase tasks run through &lt;code&gt;docker exec&lt;/code&gt; inside one selected service container. They do not execute directly on the host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nitrobase scheduler
        |
        | docker exec
        v
Selected app service
        |
        v
Application command

Host shell access: no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This matches how developers already think about application commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan queue:prune-batches
bin/rails runner "Report.generate"
node scripts/send-digest.js
python manage.py clearsessions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command runs with the filesystem, environment, packages, user, and resource limits of that container. If the application image does not contain a program, the scheduled task cannot magically use the host's copy.&lt;/p&gt;

&lt;p&gt;That limitation is intentional. The task belongs to the application, so it should live inside the application's runtime boundary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Direct arguments and shell scripts are different tools
&lt;/h2&gt;

&lt;p&gt;Nitrobase supports two command modes.&lt;/p&gt;

&lt;p&gt;The safer, simpler mode is an argument list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Program: php
Argument: artisan
Argument: reports:daily
Argument: --quiet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conceptually, this becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["php", "artisan", "reports:daily", "--quiet"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each item stays one argument. There is no shell expansion, pipe, redirection, or accidental interpretation of characters such as &lt;code&gt;;&lt;/code&gt; and &lt;code&gt;$()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Shell mode exists for tasks that genuinely need shell behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php artisan cache:prune &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; php artisan reports:daily
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;th&gt;Shell interpretation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Argument list&lt;/td&gt;
&lt;td&gt;One program with explicit arguments&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shell script&lt;/td&gt;
&lt;td&gt;Pipes, redirects, variables, multiple commands&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I prefer the argument-list mode whenever it can express the job. Shell mode is useful, but it also makes quoting, expansion, and secret handling the operator's responsibility.&lt;/p&gt;

&lt;h2&gt;
  
  
  What if a deployment starts at the same time?
&lt;/h2&gt;

&lt;p&gt;This was the first question that turned “add cron” into an operations feature.&lt;/p&gt;

&lt;p&gt;Imagine a task starts rebuilding a search index while a deployment replaces its container. Or a backup stops database writers while a scheduled import is inserting rows.&lt;/p&gt;

&lt;p&gt;Running both is unpredictable. Nitrobase already has locks for operations on servers and applications, so scheduled tasks use the same coordination layer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;03:00 scheduled task becomes due
              |
              v
     Is the app/server busy?
          /           \
        no             yes
        |               |
        v          task policy
      run          /          \
                 skip         queue
                  |             |
            record reason   wait for idle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each task can choose a collision policy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Skip&lt;/strong&gt; records that the run did not happen because the server was busy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Queue&lt;/strong&gt; waits until the conflicting operation releases its lock, up to the configured maximum wait.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Neither policy is universally correct.&lt;/p&gt;

&lt;p&gt;For a five-minute cache refresh, skipping one run may be fine. For a daily invoice process, waiting may be safer than silently losing the day's work.&lt;/p&gt;

&lt;p&gt;The important part is that the collision becomes a visible state, not a race between two unrelated shell processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  “Skipped” is not the same as “failed”
&lt;/h2&gt;

&lt;p&gt;I originally thought a run needed only three states: running, success, and failed.&lt;/p&gt;

&lt;p&gt;That was not enough to explain what actually happened.&lt;/p&gt;

&lt;p&gt;Nitrobase records these outcomes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status&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;&lt;code&gt;success&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Command exited normally with code 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;failed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Command exited with a non-zero code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;skipped&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;App was unavailable or a lock policy prevented the run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;timeout&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Command exceeded its allowed runtime&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;oom&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The container was killed for exceeding memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;killed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A signal ended the command for another reason&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These distinctions change the response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;failed  -&amp;gt; inspect application error
timeout -&amp;gt; inspect workload or raise the time limit
oom     -&amp;gt; inspect memory use and container limit
skipped -&amp;gt; inspect scheduling and lock policy
killed  -&amp;gt; inspect signals and container lifecycle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Treating all five as “cron failed” would hide the information needed to fix them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timeouts need two boundaries
&lt;/h2&gt;

&lt;p&gt;A recurring command should not be allowed to run forever merely because nobody is watching it.&lt;/p&gt;

&lt;p&gt;Nitrobase applies a timeout inside the container when the image provides the necessary shell and &lt;code&gt;timeout&lt;/code&gt; utility. It also keeps a host-side deadline around the Docker execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application command
        |
        +-- in-container timeout
        |
        +-- host-side Docker execution timeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The inner timeout can terminate the application process cleanly. The outer timeout ensures the control-plane job itself does not remain stuck if the Docker client or container behaves unexpectedly.&lt;/p&gt;

&lt;p&gt;Images without a shell still work in direct-argument mode; they simply rely on the outer execution boundary.&lt;/p&gt;

&lt;p&gt;The default run limit is five minutes, and the installation can configure its maximum. A task that legitimately needs longer can request it within that limit.&lt;/p&gt;

&lt;p&gt;The goal is not to guess the perfect duration. It is to make “unbounded” an explicit decision rather than an accidental default.&lt;/p&gt;

&lt;h2&gt;
  
  
  An exit code cannot always explain an OOM kill
&lt;/h2&gt;

&lt;p&gt;A process terminated by memory pressure may look like an ordinary signal failure. Docker also has an &lt;code&gt;OOMKilled&lt;/code&gt; flag, but that flag can remain set after an earlier incident until the container restarts.&lt;/p&gt;

&lt;p&gt;To avoid blaming the wrong run, Nitrobase checks the container's cgroup OOM-kill counter before and after the command when cgroup v2 makes it available.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OOM counter before run:  4
OOM counter after run:   5
                         ^
                         this run caused an OOM kill
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the counter is unavailable, it falls back to the Docker state transition.&lt;/p&gt;

&lt;p&gt;It is a small implementation detail, but it produces a much more useful message than “process exited 137.”&lt;/p&gt;

&lt;h2&gt;
  
  
  Output is useful, until it becomes a secret leak
&lt;/h2&gt;

&lt;p&gt;When a task fails at night, its output is usually the first thing I need in the morning.&lt;/p&gt;

&lt;p&gt;Nitrobase streams task output into the normal job log and keeps a bounded tail with the run history. The history shows whether the task was manual or scheduled, when it started, how long it ran, its exit code, and its final status.&lt;/p&gt;

&lt;p&gt;But application output can contain sensitive values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connecting with DATABASE_URL=postgres://user:password@db/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before task output is persisted, Nitrobase masks known application secret values. The masker also accounts for values split across streamed output chunks rather than assuming each chunk contains a complete line.&lt;/p&gt;

&lt;p&gt;This is a defensive layer, not a guarantee.&lt;/p&gt;

&lt;p&gt;An application may transform a secret, print only fragments, encode it, or fetch a credential at runtime that Nitrobase does not know. A safe scheduled command should still avoid echoing credentials in the first place.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Best:       command never prints the secret
Fallback:   known secret is masked from captured output
Still bad:  relying on redaction as the only protection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output is also bounded. Keeping the tail prevents one noisy task from growing the panel database indefinitely while preserving the part most likely to contain the final error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Manual runs make the schedule testable
&lt;/h2&gt;

&lt;p&gt;Waiting until 03:00 to discover a typo is not a good workflow.&lt;/p&gt;

&lt;p&gt;Every task can also be triggered manually. The manual run uses the same container boundary, lock coordination, timeout, output handling, and status classification as a scheduled run.&lt;/p&gt;

&lt;p&gt;That means the useful setup loop is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose the service.&lt;/li&gt;
&lt;li&gt;Enter the command in argument-list or shell mode.&lt;/li&gt;
&lt;li&gt;Set its timeout and busy-server policy.&lt;/li&gt;
&lt;li&gt;Run it manually.&lt;/li&gt;
&lt;li&gt;Inspect the output and exit status.&lt;/li&gt;
&lt;li&gt;Enable the cron schedule.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The manual test cannot prove that the task will always succeed, but it catches the most common configuration errors without creating a second execution path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Schedules have limits on purpose
&lt;/h2&gt;

&lt;p&gt;Nitrobase validates five-field cron expressions and rejects schedules that run more frequently than the configured minimum. By default, that minimum is five minutes.&lt;/p&gt;

&lt;p&gt;It also limits the number of tasks per application and retains only a configured number of recent runs.&lt;/p&gt;

&lt;p&gt;These limits are not meant to turn Nitrobase into a high-volume job queue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scheduled tasks are good for:
  - nightly cleanup
  - periodic reports
  - regular application maintenance
  - small imports and synchronizations

They are not a replacement for:
  - millisecond scheduling
  - distributed queues
  - thousands of concurrent jobs
  - workflow orchestration with dependencies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If an application needs retries, concurrency controls, job priorities, and durable per-item processing, that logic belongs in a proper queue or workflow system inside the application.&lt;/p&gt;

&lt;p&gt;Nitrobase handles the recurring trigger and its operational boundary. It does not pretend that cron is a distributed job platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  A scheduler restart is another boundary
&lt;/h2&gt;

&lt;p&gt;The scheduler lives in the Nitrobase process and registers enabled tasks when the panel starts. Missed application-task runs are not replayed after downtime.&lt;/p&gt;

&lt;p&gt;I think this behavior is worth stating plainly.&lt;/p&gt;

&lt;p&gt;Automatic catch-up sounds helpful, but replaying several missed maintenance commands at once after a server outage can be worse than skipping them. Some commands are not idempotent. Others are no longer relevant after their intended window.&lt;/p&gt;

&lt;p&gt;If a task must run exactly once despite downtime, its application should keep durable state and decide what work remains. The scheduler should not guess.&lt;/p&gt;

&lt;h2&gt;
  
  
  My checklist for a recurring container task
&lt;/h2&gt;

&lt;p&gt;Before enabling a new task, I now ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Is the command running in the correct service?&lt;/li&gt;
&lt;li&gt;[ ] Can it use direct arguments instead of a shell script?&lt;/li&gt;
&lt;li&gt;[ ] Is it safe to run more than once?&lt;/li&gt;
&lt;li&gt;[ ] Should it skip or queue when a deploy or backup is active?&lt;/li&gt;
&lt;li&gt;[ ] What is a realistic timeout?&lt;/li&gt;
&lt;li&gt;[ ] What happens if the process exceeds the container's memory limit?&lt;/li&gt;
&lt;li&gt;[ ] Does it print credentials, tokens, or personal data?&lt;/li&gt;
&lt;li&gt;[ ] Is its output small enough to be useful?&lt;/li&gt;
&lt;li&gt;[ ] Who receives a notification when it fails or is skipped?&lt;/li&gt;
&lt;li&gt;[ ] Has it succeeded as a manual run?&lt;/li&gt;
&lt;li&gt;[ ] Is missing a run acceptable when the panel is offline?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The cron expression is only one item because it is rarely the hardest one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem this feature is trying to solve
&lt;/h2&gt;

&lt;p&gt;I did not build scheduled tasks because writing a crontab entry is difficult.&lt;/p&gt;

&lt;p&gt;I built them because a crontab entry outside the application platform does not know when the app is moving, deploying, backing up, stopped, renamed, or failing for lack of memory.&lt;/p&gt;

&lt;p&gt;Nitrobase already holds that operational context. Bringing recurring commands into the same model means the task can follow the app and participate in the same safety boundaries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;schedule
   + container identity
   + app/server locks
   + timeout
   + classified outcome
   + bounded, masked output
   + run history and notifications
   = an operational task, not just a cron line
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is still a Beta implementation, and real workloads will expose cases I have not encountered yet. I am especially interested in feedback about collision policies, missed-run behavior, long-running maintenance commands, and the amount of output worth retaining.&lt;/p&gt;

&lt;p&gt;The lesson so far is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Scheduling a command is easy. Scheduling it without forgetting everything around the command is the real feature.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>selfhosted</category>
      <category>devops</category>
      <category>docker</category>
      <category>containers</category>
    </item>
    <item>
      <title>The Most Important MCP Feature I Added Was a 403</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Wed, 18 Nov 2026 10:00:41 +0000</pubDate>
      <link>https://dev.to/hoagminh/the-most-important-mcp-feature-i-added-was-a-403-47o5</link>
      <guid>https://dev.to/hoagminh/the-most-important-mcp-feature-i-added-was-a-403-47o5</guid>
      <description>&lt;p&gt;MCP demos usually begin with the exciting part.&lt;/p&gt;

&lt;p&gt;You connect an AI assistant to a service, ask a question in plain English, and watch it inspect schemas, explore data, or help with development work.&lt;/p&gt;

&lt;p&gt;When I looked at adding an MCP path to the Supabase template in &lt;strong&gt;Nitrobase&lt;/strong&gt;, however, my first question was less exciting:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What should happen when somebody on the public internet discovers the endpoint?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For now, the answer is deliberately boring:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt; &lt;span class="nc"&gt;Forbidden&lt;/span&gt;

&lt;span class="nc"&gt;Access&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;forbidden&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That default is the feature I care about most.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. Its MCP support is currently focused on Supabase deployments: Nitrobase preserves a dedicated route to Supabase Studio's MCP endpoint, but the route is blocked unless the server owner explicitly chooses to open it to trusted local addresses.&lt;/p&gt;

&lt;p&gt;This is not a story about giving an AI unrestricted control over a VPS. It is about making a useful interface available without quietly turning it into a public administrative surface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why MCP is useful here
&lt;/h2&gt;

&lt;p&gt;MCP, or Model Context Protocol, gives an AI client a structured way to communicate with a tool or data source.&lt;/p&gt;

&lt;p&gt;Without it, a typical database conversation becomes a copy-and-paste loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Open terminal
    |
Run a schema command
    |
Copy the output
    |
Paste it into the assistant
    |
Receive a suggested query
    |
Copy it back to the terminal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With an MCP-capable Supabase instance, the client can discover the capabilities made available by Supabase and use them in context.&lt;/p&gt;

&lt;p&gt;That can shorten tasks such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;understanding an unfamiliar database schema;&lt;/li&gt;
&lt;li&gt;investigating why an application query is failing;&lt;/li&gt;
&lt;li&gt;preparing SQL while keeping the real schema in view;&lt;/li&gt;
&lt;li&gt;exploring a development project without repeatedly exporting context;&lt;/li&gt;
&lt;li&gt;helping a teammate navigate a self-hosted Supabase stack.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The attraction is obvious: less glue work between the question and the system that contains the answer.&lt;/p&gt;

&lt;p&gt;The risk is equally obvious: the system that contains the answer may also contain production data.&lt;/p&gt;

&lt;h2&gt;
  
  
  A route is also a security boundary
&lt;/h2&gt;

&lt;p&gt;A self-hosted Supabase stack contains multiple services behind one public entry point. Nitrobase uses a reverse-proxy chain to send each path to the correct service.&lt;/p&gt;

&lt;p&gt;The MCP path looks roughly like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MCP client
    |
    | HTTPS /mcp
    v
Application reverse proxy
    |
    v
Supabase gateway
    |
    | /api/mcp
    v
Supabase Studio MCP handler
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding the path to the proxy is technically simple. Deciding what is allowed to cross it is the real work.&lt;/p&gt;

&lt;p&gt;The Nitrobase Supabase template therefore defines two boundaries:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Incoming path&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;Default result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/api/mcp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Internal Studio path&lt;/td&gt;
&lt;td&gt;Blocked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/mcp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Intended MCP entry point&lt;/td&gt;
&lt;td&gt;Blocked&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The direct internal path is denied so that it cannot become an accidental bypass. The cleaner &lt;code&gt;/mcp&lt;/code&gt; route also starts with a request-termination rule that returns &lt;code&gt;403&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In other words, deploying Supabase does &lt;strong&gt;not&lt;/strong&gt; automatically publish its MCP capability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MCP code exists        yes
Proxy route exists     yes
Public access exists   no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That distinction is easy to lose when a feature is reduced to a checkbox called “Enable MCP.”&lt;/p&gt;

&lt;h2&gt;
  
  
  Opening it should be a conscious change
&lt;/h2&gt;

&lt;p&gt;The current template includes an explicit “danger zone” in its gateway configuration. To allow MCP access, the operator must remove the default termination rule, enable IP restriction, and add the trusted local addresses.&lt;/p&gt;

&lt;p&gt;A simplified version of the intended policy 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;plugins&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;ip-restriction&lt;/span&gt;
    &lt;span class="na"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;allow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;127.0.0.1&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;10.0.0.24&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important part is not the YAML syntax. It is the decision represented by each address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Who needs MCP access?
        |
        +-- AI client on the same machine -&amp;gt; loopback address
        |
        +-- Client over a private network -&amp;gt; private/VPN address
        |
        +-- Everyone on the internet      -&amp;gt; do not allow by default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An allowlist is not complete authentication, and it is not a substitute for transport security or Supabase's own authorization model. It is one boundary that reduces the number of machines that can even reach the endpoint.&lt;/p&gt;

&lt;p&gt;For a Beta product, I prefer making that boundary visible over pretending that every possible MCP client and network topology can be configured safely with one universal switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I did not make it public after deployment
&lt;/h2&gt;

&lt;p&gt;Nitrobase already knows how to give an application an HTTPS route. It would have been easy to make &lt;code&gt;/mcp&lt;/code&gt; immediately reachable and describe that as a smoother onboarding experience.&lt;/p&gt;

&lt;p&gt;But convenience at deployment time can create ambiguity later:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Was the endpoint opened for local development or production use?&lt;/li&gt;
&lt;li&gt;Does the client run on the VPS, a laptop, or a hosted AI service?&lt;/li&gt;
&lt;li&gt;Which database role does the MCP server use?&lt;/li&gt;
&lt;li&gt;Can the available tools only inspect state, or can they change it?&lt;/li&gt;
&lt;li&gt;Are prompts and tool results leaving the operator's network?&lt;/li&gt;
&lt;li&gt;Will the endpoint still be exposed after the experiment ends?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nitrobase cannot answer those questions merely because it installed the stack.&lt;/p&gt;

&lt;p&gt;So the safer default is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy capability -&amp;gt; keep it closed -&amp;gt; understand the client -&amp;gt; open the narrowest path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds one manual step, but it prevents an infrastructure template from making a security decision on behalf of every user.&lt;/p&gt;

&lt;h2&gt;
  
  
  MCP does not remove the need to understand permissions
&lt;/h2&gt;

&lt;p&gt;Structured tools are better than asking an assistant to improvise shell commands, but “structured” does not automatically mean “safe.”&lt;/p&gt;

&lt;p&gt;There are several separate layers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Question to answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Network&lt;/td&gt;
&lt;td&gt;Which clients can reach &lt;code&gt;/mcp&lt;/code&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transport&lt;/td&gt;
&lt;td&gt;Is the connection protected in transit?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Authentication&lt;/td&gt;
&lt;td&gt;How does the server know who the client is?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database role&lt;/td&gt;
&lt;td&gt;What data and operations can the session access?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tool policy&lt;/td&gt;
&lt;td&gt;Which MCP tools may the assistant call?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Human approval&lt;/td&gt;
&lt;td&gt;Which changes require confirmation?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logging&lt;/td&gt;
&lt;td&gt;Can sensitive arguments or results appear in logs?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;An IP allowlist only answers the first question.&lt;/p&gt;

&lt;p&gt;If an MCP server can execute an operation, a connected client may eventually attempt that operation. The database permissions behind the connection remain the final enforcement point, so a development assistant should not inherit a production superuser role merely because its interface looks friendly.&lt;/p&gt;

&lt;p&gt;I use this mental model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assistant intention
      !=
MCP tool definition
      !=
Database permission
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each layer should assume the layer above can make a mistake.&lt;/p&gt;

&lt;h2&gt;
  
  
  A practical workflow for a self-hosted setup
&lt;/h2&gt;

&lt;p&gt;If I were enabling the current MCP route for my own development environment, I would do it in this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Decide where the MCP client will run.&lt;/li&gt;
&lt;li&gt;Prefer the same host or a private network instead of a public source address.&lt;/li&gt;
&lt;li&gt;Allow only that source in the Supabase gateway configuration.&lt;/li&gt;
&lt;li&gt;Use HTTPS even when an endpoint is allowlisted.&lt;/li&gt;
&lt;li&gt;Give the underlying database identity only the permissions needed for the task.&lt;/li&gt;
&lt;li&gt;Inspect the tools exposed by the server before approving calls.&lt;/li&gt;
&lt;li&gt;Test with non-production data first.&lt;/li&gt;
&lt;li&gt;Remove the allowlist entry when the integration is no longer used.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The resulting path should be narrow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;One known client
      |
Private or restricted network
      |
HTTPS /mcp
      |
Supabase authorization
      |
Least-privileged database access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If any box is unclear, leaving the default &lt;code&gt;403&lt;/code&gt; in place is a perfectly valid outcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Nitrobase currently does -- and does not do
&lt;/h2&gt;

&lt;p&gt;The current Beta behavior is intentionally small.&lt;/p&gt;

&lt;p&gt;Nitrobase does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;deploy a self-hosted Supabase stack;&lt;/li&gt;
&lt;li&gt;preserve a dedicated &lt;code&gt;/mcp&lt;/code&gt; proxy path;&lt;/li&gt;
&lt;li&gt;block the direct &lt;code&gt;/api/mcp&lt;/code&gt; path;&lt;/li&gt;
&lt;li&gt;block &lt;code&gt;/mcp&lt;/code&gt; by default;&lt;/li&gt;
&lt;li&gt;provide a configuration pattern for restricting access to trusted IPs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nitrobase does not currently turn the whole control panel into an MCP server. An assistant is not being given a Nitrobase tool that can deploy applications, delete volumes, rotate secrets, or operate every connected VPS.&lt;/p&gt;

&lt;p&gt;It also does not automatically determine whether a particular AI client, database role, or network is trustworthy. Those decisions still belong to the server owner.&lt;/p&gt;

&lt;p&gt;I think stating this boundary matters. “Nitrobase supports MCP” should not be interpreted as “connect an AI and give it root.” In the current implementation, it means Nitrobase's Supabase deployment understands the MCP route and starts from a closed network policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  My MCP exposure checklist
&lt;/h2&gt;

&lt;p&gt;Before removing that &lt;code&gt;403&lt;/code&gt;, I want clear answers to these questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this a development, staging, or production database?&lt;/li&gt;
&lt;li&gt;Where does the MCP client execute?&lt;/li&gt;
&lt;li&gt;Can it connect through loopback, a VPN, or a private network?&lt;/li&gt;
&lt;li&gt;Is &lt;code&gt;/api/mcp&lt;/code&gt; still blocked as a direct path?&lt;/li&gt;
&lt;li&gt;Is &lt;code&gt;/mcp&lt;/code&gt; limited to explicit source addresses?&lt;/li&gt;
&lt;li&gt;Is the connection protected with HTTPS?&lt;/li&gt;
&lt;li&gt;Which identity and database role will the MCP session use?&lt;/li&gt;
&lt;li&gt;Which operations can that role perform?&lt;/li&gt;
&lt;li&gt;Does the client ask before write or destructive operations?&lt;/li&gt;
&lt;li&gt;Could tool inputs or results contain secrets or personal data?&lt;/li&gt;
&lt;li&gt;Is there a plan to remove access when it is no longer needed?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The checklist is intentionally longer than the configuration snippet. The line that enables access is short; the trust decision behind it is not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem this feature is trying to solve
&lt;/h2&gt;

&lt;p&gt;I want self-hosting to work with newer developer tools without requiring people to publish every new protocol endpoint the moment it appears.&lt;/p&gt;

&lt;p&gt;MCP can make a database easier to understand and operate through an AI-assisted workflow. Nitrobase can make the underlying Supabase stack easier to deploy on infrastructure the user owns.&lt;/p&gt;

&lt;p&gt;The useful combination is not simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;self-hosted Supabase + AI = convenience
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;self-hosted Supabase
        +
an explicit MCP route
        +
a closed-by-default boundary
        +
permissions chosen by the owner
        =
convenience with a place to apply control
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is more work to do. I would like Nitrobase to make trusted-client setup easier, show the active exposure clearly, and help operators understand the permissions behind an MCP connection without hiding the security model.&lt;/p&gt;

&lt;p&gt;For now, the most honest first version is an endpoint that exists, a route that is understood, and a default response that says no.&lt;/p&gt;

&lt;p&gt;Sometimes the best way to ship a powerful feature is to begin with a good &lt;code&gt;403&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>supabase</category>
      <category>selfhosted</category>
      <category>security</category>
    </item>
    <item>
      <title>Encrypting Secrets at Rest Is Not the Same as Keeping Them Secret</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Tue, 17 Nov 2026 07:46:08 +0000</pubDate>
      <link>https://dev.to/hoagminh/encrypting-secrets-at-rest-is-not-the-same-as-keeping-them-secret-307k</link>
      <guid>https://dev.to/hoagminh/encrypting-secrets-at-rest-is-not-the-same-as-keeping-them-secret-307k</guid>
      <description>&lt;p&gt;Every deployment platform eventually asks for something sensitive.&lt;/p&gt;

&lt;p&gt;An SSH private key to reach a server. A database password. An S3 credential for backups. A Git token. An application secret that must become an environment variable inside a container.&lt;/p&gt;

&lt;p&gt;The easy security claim would be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Everything is encrypted.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That sentence sounds reassuring, but it leaves out the questions that actually matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which values can be hashed instead of encrypted?&lt;/li&gt;
&lt;li&gt;Which values must be recovered in plaintext to perform their job?&lt;/li&gt;
&lt;li&gt;Where does the encryption key live?&lt;/li&gt;
&lt;li&gt;Who is allowed to reveal a value?&lt;/li&gt;
&lt;li&gt;Does the reveal leave an audit record?&lt;/li&gt;
&lt;li&gt;Can a secret leak through build arguments or logs?&lt;/li&gt;
&lt;li&gt;What does encryption no longer protect after the panel is compromised?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These questions shaped how I approached &lt;strong&gt;secret handling in Nitrobase&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. I do not consider its existence a substitute for a dedicated secrets manager, host hardening, or a security review. The goal is more practical: understand the different kinds of sensitive data a self-hosted PaaS handles and avoid treating all of them as interchangeable strings in a database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the operation the system needs
&lt;/h2&gt;

&lt;p&gt;Before choosing between hashing and encryption, I ask what Nitrobase must do with the value later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Does Nitrobase need the original value again?
                  │
          ┌───────┴───────┐
          │               │
         No              Yes
          │               │
          ▼               ▼
        Hash            Encrypt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examples make the distinction clearer:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sensitive value&lt;/th&gt;
&lt;th&gt;Must recover the original?&lt;/th&gt;
&lt;th&gt;Storage approach&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;User password&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Password hash&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API token&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Token hash; raw token shown once&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2FA recovery code&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Hash; code is one-time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSH private key&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Encrypted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSH passphrase&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Encrypted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backup destination secret&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Encrypted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application environment secret&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Encrypted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TOTP seed&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Encrypted&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If Nitrobase only needs to answer “does this submitted value match?”, storing the original would add unnecessary risk.&lt;/p&gt;

&lt;p&gt;If Nitrobase must later authenticate to a VPS or generate an application's runtime environment, a one-way hash is not enough. The original value must be recoverable, so encryption is required.&lt;/p&gt;

&lt;p&gt;Security begins with not storing what the system does not need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recoverable secrets have an unavoidable plaintext moment
&lt;/h2&gt;

&lt;p&gt;Consider an SSH private key.&lt;/p&gt;

&lt;p&gt;Nitrobase stores it encrypted in PostgreSQL. When a job connects to the server, the panel must decrypt it and give it to the SSH client in memory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Encrypted database value
          │
          ▼
Decrypt inside the running panel
          │
          ▼
Use for one SSH operation
          │
          ▼
Do not return it to the browser or job log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same principle applies to application variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Encrypted app environment
          │
          ▼
Render deployment files
          │
          ▼
Transfer to the managed VPS
          │
          ▼
Container receives plaintext at runtime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Encryption at rest protects the stored representation. It cannot keep a value encrypted while software actively uses that value as a password or API key.&lt;/p&gt;

&lt;p&gt;This matters for the threat model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stolen database dump without ENCRYPTION_KEY     → encrypted values protected
Backup archive without ENCRYPTION_KEY           → archive unreadable
Read-only user without secret permission        → values hidden
Compromised running panel with key access        → secrets may be exposed
Root access to the managed application server   → runtime secrets may be exposed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last two lines are why “encrypted at rest” should never be presented as complete protection.&lt;/p&gt;

&lt;h2&gt;
  
  
  One installation key protects many categories of secret
&lt;/h2&gt;

&lt;p&gt;Nitrobase derives encryption keys from the installation's &lt;code&gt;ENCRYPTION_KEY&lt;/code&gt; and uses authenticated encryption for stored credentials.&lt;/p&gt;

&lt;p&gt;The encrypted columns include values such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSH private keys, passwords, and passphrases;&lt;/li&gt;
&lt;li&gt;application and custom Compose environment values;&lt;/li&gt;
&lt;li&gt;database and link credentials;&lt;/li&gt;
&lt;li&gt;backup destination credentials;&lt;/li&gt;
&lt;li&gt;notification channel secrets;&lt;/li&gt;
&lt;li&gt;Git and cloud connection tokens;&lt;/li&gt;
&lt;li&gt;TOTP seeds;&lt;/li&gt;
&lt;li&gt;Cloudflare Tunnel connector tokens.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The operational consequence is simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nitrobase database + ENCRYPTION_KEY = usable control-plane state
Nitrobase database − ENCRYPTION_KEY = encrypted fields cannot be recovered
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The installer writes generated secrets to a file with restrictive permissions and tells the administrator to keep a copy outside the machine.&lt;/p&gt;

&lt;p&gt;That external copy is not optional recovery documentation. It is part of the cryptographic system.&lt;/p&gt;

&lt;h2&gt;
  
  
  The key should not live inside the backup it unlocks
&lt;/h2&gt;

&lt;p&gt;Nitrobase self-backups contain the panel database, including encrypted infrastructure credentials. The archive is also encrypted using the installation key.&lt;/p&gt;

&lt;p&gt;Putting &lt;code&gt;ENCRYPTION_KEY&lt;/code&gt; inside that archive would make the archive self-decrypting. Keeping the only copy beside the panel would create the opposite failure: the backup survives, but nobody can open it after the panel server disappears.&lt;/p&gt;

&lt;p&gt;The recovery kit therefore has two separate pieces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Off-site backup destination
└── nitrobase-backup.tar.gz.enc

Separate password manager / offline record
├── ENCRYPTION_KEY
├── backup destination access
└── recorded SHA-256 checksum
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Separation creates inconvenience during recovery, but it prevents the backup from carrying its own decryption capability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Secret reveal is an action, not a display preference
&lt;/h2&gt;

&lt;p&gt;Masking a password field with dots is not access control. If every authenticated user can click an eye icon, the value is still broadly available.&lt;/p&gt;

&lt;p&gt;Nitrobase separates ordinary read access from secret access through team permissions. A viewer can inspect infrastructure state without automatically receiving plaintext credentials.&lt;/p&gt;

&lt;p&gt;When an authorized user explicitly reveals a stored secret:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;the UI asks for confirmation;&lt;/li&gt;
&lt;li&gt;the server checks the permission again;&lt;/li&gt;
&lt;li&gt;the plaintext value is returned for that action;&lt;/li&gt;
&lt;li&gt;the reveal is written to the audit log.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“Can view the application”
              ≠
“Can reveal its credentials”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The audit record does not make disclosure safe, but it changes disclosure from an invisible UI event into an accountable administrative action.&lt;/p&gt;

&lt;p&gt;For some secrets, Nitrobase avoids reveal entirely. Build secrets can be added, replaced, or removed, but are not shown again after storage. API tokens and certain generated passwords are displayed once; only a hash or no reusable copy remains afterward.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build arguments are not a place for secrets
&lt;/h2&gt;

&lt;p&gt;Container builds introduce a different leak path.&lt;/p&gt;

&lt;p&gt;A value passed as a normal build argument can become visible in build history, cache metadata, or an image layer depending on how the Dockerfile uses it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="c"&gt;# Poor secret boundary&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt; NPM_TOKEN
&lt;span class="k"&gt;RUN&lt;/span&gt; npm config &lt;span class="nb"&gt;set&lt;/span&gt; //registry.npmjs.org/:_authToken &lt;span class="s2"&gt;"$NPM_TOKEN"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nitrobase separates build arguments from build secrets. Build secrets are passed through BuildKit's secret mount mechanism:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN&lt;/span&gt; --mount=type=secret,id=NPM_TOKEN \
    &lt;span class="nv"&gt;NPM_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$(cat /run/secrets/NPM_TOKEN)"&lt;/span&gt; npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The intent is that the secret exists for the build step without becoming a build argument or being copied into the final image layer.&lt;/p&gt;

&lt;p&gt;This still depends on the Dockerfile behaving correctly. A build step can deliberately print or copy the mounted secret. The platform can provide the safer transport, but it cannot make untrusted build instructions honest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Logs need a separate defensive layer
&lt;/h2&gt;

&lt;p&gt;Encrypting the database does nothing if the same credential appears in a job error.&lt;/p&gt;

&lt;p&gt;Operational commands fail, and external tools often include their arguments, URLs, or response details in stderr. A backup client may print an endpoint containing credentials. An SSH error may contain connection details. A webhook failure may echo part of its request configuration.&lt;/p&gt;

&lt;p&gt;Nitrobase treats likely secret-bearing fields as sensitive when creating audit metadata and error output. Services that execute commands also redact known destination and credential values before job errors are persisted or displayed.&lt;/p&gt;

&lt;p&gt;But log redaction has an important limitation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is a last defensive layer, not proof that arbitrary output contains no secret.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An application can print its own environment. A custom script can echo a token. A malformed third-party error can expose a value in an unexpected format.&lt;/p&gt;

&lt;p&gt;The safer pattern is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Do not put the secret in command-line text when avoidable
                     ↓
Use files, stdin, environment, or dedicated secret mounts
                     ↓
Redact known values from captured output
                     ↓
Restrict who can read job logs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each layer assumes the previous one can fail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authentication protects the door to secret operations
&lt;/h2&gt;

&lt;p&gt;Secret storage does not help if an attacker can simply sign in as an administrator.&lt;/p&gt;

&lt;p&gt;Nitrobase includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;password authentication;&lt;/li&gt;
&lt;li&gt;optional TOTP two-factor authentication;&lt;/li&gt;
&lt;li&gt;one-time hashed recovery codes;&lt;/li&gt;
&lt;li&gt;persistent rate-limit state for sign-in and 2FA attempts;&lt;/li&gt;
&lt;li&gt;team roles and scoped permissions;&lt;/li&gt;
&lt;li&gt;expiring API tokens with explicit scopes;&lt;/li&gt;
&lt;li&gt;audit records for administrative actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These controls reduce common account-level risks, but they do not replace putting the panel behind HTTPS, restricting network exposure, maintaining the host, and protecting administrator email accounts.&lt;/p&gt;

&lt;p&gt;The control plane is valuable precisely because it holds access to other systems. It should be treated as privileged infrastructure, not as an ordinary dashboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key rotation is a migration, not a string replacement
&lt;/h2&gt;

&lt;p&gt;Changing &lt;code&gt;ENCRYPTION_KEY&lt;/code&gt; in an environment file without migrating existing ciphertext makes stored secrets unreadable.&lt;/p&gt;

&lt;p&gt;A safe rotation needs to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;stop operations that might write new secrets;&lt;/li&gt;
&lt;li&gt;decrypt every encrypted field using the current key;&lt;/li&gt;
&lt;li&gt;encrypt it again with the new key;&lt;/li&gt;
&lt;li&gt;update the installation configuration;&lt;/li&gt;
&lt;li&gt;retain access to previous keys while old backups still exist.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;current database secrets      K1 ── migrate ──► K2
old application backups      K1 ──────────────► keep K1 available
new application backups      K2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database migration may be complete while the backup lifecycle is not. Deleting the old key too early can invalidate recovery points still inside their retention window.&lt;/p&gt;

&lt;p&gt;Nitrobase supports previous keys for this reason. An old key should remain available until every archive created with it has expired or been replaced.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this security model does not protect against
&lt;/h2&gt;

&lt;p&gt;It is useful to state the boundaries plainly.&lt;/p&gt;

&lt;p&gt;Encryption at rest does not protect secrets when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the running panel process is compromised and can access the key;&lt;/li&gt;
&lt;li&gt;an attacker obtains root on the panel host;&lt;/li&gt;
&lt;li&gt;an attacker obtains root on a managed VPS and reads runtime configuration;&lt;/li&gt;
&lt;li&gt;an application deliberately logs its own secret;&lt;/li&gt;
&lt;li&gt;an authorized administrator reveals and copies a credential;&lt;/li&gt;
&lt;li&gt;a malicious image misuses the environment provided to it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nitrobase is a system that must use infrastructure credentials. It is not a zero-knowledge service in which the server can operate without ever accessing plaintext.&lt;/p&gt;

&lt;p&gt;The security objective is therefore layered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Minimize what is stored
        ↓
Hash values that need only verification
        ↓
Encrypt values that must be recovered
        ↓
Restrict and audit plaintext access
        ↓
Reduce exposure during build and execution
        ↓
Make key loss and compromise part of recovery planning
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  My secret-handling checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Does the system need to recover this value, or can it store only a hash?&lt;/li&gt;
&lt;li&gt;[ ] Is the secret encrypted before it reaches persistent storage?&lt;/li&gt;
&lt;li&gt;[ ] Is its encryption key stored outside the database and backups?&lt;/li&gt;
&lt;li&gt;[ ] Can read-only users see or reveal it?&lt;/li&gt;
&lt;li&gt;[ ] Is an explicit reveal recorded in the audit log?&lt;/li&gt;
&lt;li&gt;[ ] Can the value appear in a command line, build layer, or job log?&lt;/li&gt;
&lt;li&gt;[ ] Is the runtime destination trusted to receive the plaintext?&lt;/li&gt;
&lt;li&gt;[ ] Can the key be rotated without invalidating retained backups?&lt;/li&gt;
&lt;li&gt;[ ] Has recovery been tested with only the backup and external recovery kit?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The checklist is more useful to me than the statement “we encrypt secrets,” because it follows the value through its whole lifecycle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem this work is trying to solve
&lt;/h2&gt;

&lt;p&gt;A self-hosted PaaS sits between people and infrastructure. To reduce repetitive work, it receives credentials powerful enough to deploy applications, access servers, restore databases, and modify routing.&lt;/p&gt;

&lt;p&gt;Pretending those values never become plaintext would be misleading. Leaving them unprotected because the panel needs them would be irresponsible.&lt;/p&gt;

&lt;p&gt;Nitrobase tries to occupy the practical space between those extremes: hash what does not need recovery, encrypt what does, make plaintext access deliberate, reduce accidental exposure, and document where the protection ends.&lt;/p&gt;

&lt;p&gt;It is still Beta, and security-sensitive behavior needs scrutiny from environments and threat models beyond my own. Feedback on the key hierarchy, secret-reveal model, log redaction, and recovery process is especially valuable.&lt;/p&gt;

&lt;p&gt;The principle I want to preserve is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A secret is not secure merely because its database column is encrypted. Its entire journey matters.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>selfhosted</category>
      <category>devops</category>
      <category>secrets</category>
    </item>
    <item>
      <title>I Stopped Copying Database URLs Between .env Files</title>
      <dc:creator>hoagminh</dc:creator>
      <pubDate>Mon, 16 Nov 2026 09:39:11 +0000</pubDate>
      <link>https://dev.to/hoagminh/i-stopped-copying-database-urls-between-env-files-4m6g</link>
      <guid>https://dev.to/hoagminh/i-stopped-copying-database-urls-between-env-files-4m6g</guid>
      <description>&lt;p&gt;Connecting an application to a database sounds like one configuration change:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DATABASE_URL=postgresql://user:password@host:5432/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In practice, I kept repeating a longer sequence:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;create the database;&lt;/li&gt;
&lt;li&gt;find its host and port;&lt;/li&gt;
&lt;li&gt;copy the username and password;&lt;/li&gt;
&lt;li&gt;build the connection URL without breaking its escaping;&lt;/li&gt;
&lt;li&gt;paste it into the application's environment;&lt;/li&gt;
&lt;li&gt;make sure both containers share a network;&lt;/li&gt;
&lt;li&gt;restart or redeploy the application;&lt;/li&gt;
&lt;li&gt;remember where that credential was copied when it needs to change.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The connection string was only the visible part. The real relationship contained both &lt;strong&gt;configuration&lt;/strong&gt; and &lt;strong&gt;network access&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is the problem behind &lt;strong&gt;database links&lt;/strong&gt; in Nitrobase.&lt;/p&gt;

&lt;p&gt;Nitrobase has only recently launched and is still in &lt;strong&gt;Beta&lt;/strong&gt;. This feature does not try to become a database proxy or a service mesh. Its purpose is smaller: connect an application and a database on the same VPS through an isolated Docker network, then give the application the correct connection values without requiring manual copy-and-paste.&lt;/p&gt;

&lt;h2&gt;
  
  
  A URL alone does not create connectivity
&lt;/h2&gt;

&lt;p&gt;Suppose I add this environment variable to an application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DATABASE_URL=postgresql://app:secret@database:5432/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That value is useful only if &lt;code&gt;database&lt;/code&gt; resolves to the correct container and the application can reach it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application configuration   ✅ has DATABASE_URL
Docker networking           ❓ can “database” be resolved?
Database permissions        ❓ can this login access “app”?
Runtime state               ❓ has the application been restarted?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The opposite is also possible: two containers share a network, but the application has no credential with which to authenticate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;network without credentials      = reachable but unusable
credentials without a network    = configured but unreachable
network + credentials            = an actual connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nitrobase treats the link as the combination of those pieces.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when I link a database?
&lt;/h2&gt;

&lt;p&gt;A database link connects one managed database to one application on the same server.&lt;/p&gt;

&lt;p&gt;The workflow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Choose database + application
             │
             ▼
Create a private per-link Docker network
             │
      ┌──────┴──────┐
      ▼             ▼
attach database   attach app services
      │             │
      └──────┬──────┘
             ▼
Generate DATABASE_URL and selected env values
             │
             ▼
Redeploy the app so it receives them
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application receives a full connection URL using an internal container address. Optionally, Nitrobase can also provide the individual parts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DATABASE_URL=postgresql://app:secret@database-container:5432/app
DATABASE_HOST=database-container
DATABASE_PORT=5432
DATABASE_USER=app
DATABASE_PASSWORD=secret
DATABASE_NAME=app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact variable names depend on the database engine and can be changed during linking to match what the application expects.&lt;/p&gt;

&lt;h2&gt;
  
  
  One relationship, one private network
&lt;/h2&gt;

&lt;p&gt;I did not want every application on a VPS to join one large shared database network.&lt;/p&gt;

&lt;p&gt;Instead, each link receives its own internal Docker network:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                VPS
┌──────────────────────────────────────────┐
│                                          │
│  app-a ───── private link A ─────┐       │
│                                  ▼       │
│                              PostgreSQL  │
│                                  ▲       │
│  app-b ───── private link B ─────┘       │
│                                          │
│  app-c ✕ no link, no database network    │
│                                          │
└──────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;app-a&lt;/code&gt; and &lt;code&gt;app-b&lt;/code&gt; can reach the database because each has an explicit link. &lt;code&gt;app-c&lt;/code&gt; does not receive access merely because it happens to run on the same VPS.&lt;/p&gt;

&lt;p&gt;The networks are created as internal networks. The database remains unavailable from outside the host unless its port is separately published.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Connection path&lt;/th&gt;
&lt;th&gt;Available by default?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Linked application → database&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unlinked application → database&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internet → database port&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSH tunnel → loopback-published port&lt;/td&gt;
&lt;td&gt;Only when configured&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;External network → published port&lt;/td&gt;
&lt;td&gt;Only when explicitly enabled&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This keeps “the database exists on this server” separate from “the database should accept connections from the network.”&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the network does not use a friendly shared service name
&lt;/h2&gt;

&lt;p&gt;Docker Compose normally makes service names available through DNS on a Compose network. That is convenient inside one application:&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;api&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_HOST&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;db&lt;/span&gt;
  &lt;span class="na"&gt;db&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;postgres&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It becomes risky on a network shared by unrelated Compose projects.&lt;/p&gt;

&lt;p&gt;Imagine two applications, both with a service named &lt;code&gt;db&lt;/code&gt;. If those services join the same shared network under that alias, the name may no longer identify the intended database reliably.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app-one/db ──┐
             ├── shared alias “db” ──► ambiguous
app-two/db ──┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nitrobase avoids declaring the link network directly in either Compose file. After deployment, it attaches containers by their unique container names. The generated connection URL uses the database container's unique name rather than a generic service alias.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db                                      ❌ potentially ambiguous
database-a1b2c3d4-db                    ✅ identifies one container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is a small implementation detail, but it prevents one application's ordinary service name from colliding with another application's database path.&lt;/p&gt;

&lt;h2&gt;
  
  
  A link should not require the database superuser
&lt;/h2&gt;

&lt;p&gt;The fastest way to connect an application is to reuse the database's main login. It is also usually more access than the application needs.&lt;/p&gt;

&lt;p&gt;Nitrobase can link with either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the database's main credential; or&lt;/li&gt;
&lt;li&gt;another login created for a specific application and database.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Main database login
├── administrative access
├── maintenance operations
└── broad permissions

Application login
├── one application
├── one database
└── only the permissions it needs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second model reduces the impact of an application credential being exposed. It also makes ownership clearer: when the application is retired, its database login can be removed without rotating the credential used by every other service.&lt;/p&gt;

&lt;p&gt;Nitrobase does not infer the ideal permission model for arbitrary software. The database user and grants still need to match the application. The link simply makes it practical to use a dedicated credential rather than encouraging reuse through copy-and-paste convenience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I prefer injecting the URL over displaying it repeatedly
&lt;/h2&gt;

&lt;p&gt;Every time a connection string is copied, it gains another place where it can remain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database page
    ↓ copy
clipboard history
    ↓ paste
local notes
    ↓ paste
.env file
    ↓ maybe commit
repository history
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nitrobase stores database passwords and link credentials encrypted. When an application is rendered for deployment, the link produces the environment values that application needs.&lt;/p&gt;

&lt;p&gt;The goal is not to claim the secret never reaches the application—it must, or authentication cannot work. The goal is to reduce unnecessary handling and avoid turning the connection URL into a value that people repeatedly move through browsers, chat, notes, and repositories.&lt;/p&gt;

&lt;h2&gt;
  
  
  Linking and redeploying are separate decisions
&lt;/h2&gt;

&lt;p&gt;Creating a link changes the desired relationship, but a running container does not gain new environment variables dynamically.&lt;/p&gt;

&lt;p&gt;The application needs to be recreated with the new environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create link
    │
    ├── network can be prepared
    └── env is part of next application render
             │
             ▼
          redeploy
             │
             ▼
application starts with DATABASE_URL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The link dialog can redeploy the application immediately. It can also save the relationship without redeploying, which is useful when several configuration changes should be applied together.&lt;/p&gt;

&lt;p&gt;This distinction avoids pretending that updating configuration in a control panel magically changes the environment of an already-running process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why links currently require the same server
&lt;/h2&gt;

&lt;p&gt;A Docker network exists on one Docker host. It cannot privately attach a container running on another VPS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPS A: application ──────╳────── database : VPS B
                         no shared local Docker network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nitrobase therefore links only applications and databases on the same managed server.&lt;/p&gt;

&lt;p&gt;For applications on another server, the choices are different:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;move the application or database so they share a host;&lt;/li&gt;
&lt;li&gt;publish the database port and protect it with a firewall or private network;&lt;/li&gt;
&lt;li&gt;use an external tunnel or VPN designed for cross-server connectivity.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I prefer an explicit limitation here. Calling a public database address a “private link” would hide a meaningful change in the security boundary.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when the database moves?
&lt;/h2&gt;

&lt;p&gt;A hard-coded connection URL combines identity and location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protocol + username + password + hostname + port + database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the database is restored as a new application or moved to another server, some of those parts may change.&lt;/p&gt;

&lt;p&gt;The link is useful because Nitrobase knows which application and database the relationship belongs to. When the application is rendered, the connection values are derived from the current internal endpoint and stored login rather than from a string somebody copied months ago.&lt;/p&gt;

&lt;p&gt;This does not eliminate every migration step—cross-server networking still needs an explicit design—but it gives the platform a structured relationship to update instead of an opaque value hidden in an &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;

&lt;h2&gt;
  
  
  My checklist before connecting an application
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Are the application and database on the same VPS?&lt;/li&gt;
&lt;li&gt;Does the application expect a full URL or separate connection fields?&lt;/li&gt;
&lt;li&gt;Is the chosen environment variable name correct?&lt;/li&gt;
&lt;li&gt;Can I use a dedicated database login instead of the main account?&lt;/li&gt;
&lt;li&gt;Does that login have only the permissions the application needs?&lt;/li&gt;
&lt;li&gt;Is the database port still private unless external access is required?&lt;/li&gt;
&lt;li&gt;Will the application be redeployed now or during a maintenance window?&lt;/li&gt;
&lt;li&gt;Does the application health check prove the database connection works?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last item matters. A successful container start does not prove that migrations completed or that the application can query its database.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem this feature is trying to solve
&lt;/h2&gt;

&lt;p&gt;Copying a connection string is easy. Maintaining the relationship it represents is harder.&lt;/p&gt;

&lt;p&gt;A useful database link needs to answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which application is allowed to reach this database?&lt;/li&gt;
&lt;li&gt;Through which network path?&lt;/li&gt;
&lt;li&gt;Which login does it use?&lt;/li&gt;
&lt;li&gt;Which environment variables should it receive?&lt;/li&gt;
&lt;li&gt;When does the running container pick up those values?&lt;/li&gt;
&lt;li&gt;What must change if either side moves?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nitrobase tries to make those answers part of one managed relationship instead of spreading them across Docker networks, password managers, &lt;code&gt;.env&lt;/code&gt; files, and deployment notes.&lt;/p&gt;

&lt;p&gt;It is still a Beta feature and needs testing with more frameworks, database clients, and unusual connection formats. But the principle is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Connecting an application to a database should establish both the route and the credential—not leave half of the relationship in someone's clipboard.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nitrobase source code: &lt;a href="https://github.com/AydenGroup/nitrobase" rel="noopener noreferrer"&gt;https://github.com/AydenGroup/nitrobase&lt;/a&gt;&lt;/p&gt;

</description>
      <category>selfhosted</category>
      <category>docker</category>
      <category>database</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
