Repository navigation
docs: keep the registry mirror reachable only from workspaces - #263
Merged
Merged
Conversation
## Short Summary (TL;DR) The documented registry mirror was open to the whole internet, and its UFW rule could not close it. The docs now run the mirror with `--network host` and allow port 5000 only from Docker's addresses. ## The Issue The server setup docs opened port 5000 to everyone with `ufw allow 5000`. The mirror's systemd unit also published the port with `docker run -p 0.0.0.0:5000:5000`. Docker's rules for a published port take effect before UFW's, so even a narrower UFW rule left the mirror open. Anyone could pull images through it, using the host's bandwidth and filling the disk it shares with Coder and the workspaces. Both coder.ddev.com and staging-coder.ddev.com were set up this way, and both mirrors answered requests from outside. ## How This PR Solves The Issue - Step 2's firewall rule allows port 5000 only from `172.16.0.0/12`, Docker's default address range. Workspaces reach the mirror at the host's public name, and the host sees those connections coming from their Docker addresses. - The systemd unit runs the registry with `--network host` instead of publishing the port, so UFW applies to it. - Step 3 explains how to check the host's Docker subnets against that range, and how to fix an existing unit that still uses `-p`. ## Manual Testing Instructions Both hosts already run this configuration. On a host set up this way, from a machine outside it: ```bash curl -s --max-time 5 http://<coder-host>:5000/v2/ || echo blocked ``` Expect `blocked`. Inside a workspace on that host: ```bash docker info | grep -A1 'Registry Mirrors' docker pull hello-world ``` Expect the host's mirror in the list, and a successful pull. ## Automated Testing Overview Claude Code ran markdownlint with `.markdownlint.jsonc` on the changed page, which passed. Nobody ran the strict Zensical build locally, so CI's docs check covers it. Claude Code checked the configuration itself on both hosts: each mirror timed out from the other host, and a workspace on each host still found its mirror and pulled through it. ## Release/Deployment Notes coder.ddev.com and staging-coder.ddev.com already use this configuration. Other self-hosted installs should apply the unit change and the firewall rule from Step 3. 🤖 Developed with assistance from [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3Cc2G6867sD8ZdDCVZ7Em
Documentation build overview
|
PreviewsThe start.coder.ddev.com landing-page preview has been removed. Read the Docs keeps or removes its own docs preview. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Short Summary (TL;DR)
The documented registry mirror was open to the whole internet, and its UFW rule could not close it. The docs now run the mirror with
--network hostand allow port 5000 only from Docker's addresses.The Issue
The server setup docs opened port 5000 to everyone with
ufw allow 5000. The mirror's systemd unit also published the port withdocker run -p 0.0.0.0:5000:5000. Docker's rules for a published port take effect before UFW's, so even a narrower UFW rule left the mirror open. Anyone could pull images through it, using the host's bandwidth and filling the disk it shares with Coder and the workspaces. Both coder.ddev.com and staging-coder.ddev.com were set up this way, and both mirrors answered requests from outside.How This PR Solves The Issue
172.16.0.0/12, Docker's default address range. Workspaces reach the mirror at the host's public name, and the host sees those connections coming from their Docker addresses.--network hostinstead of publishing the port, so UFW applies to it.-p.Manual Testing Instructions
Both hosts already run this configuration. On a host set up this way, from a machine outside it:
Expect
blocked. Inside a workspace on that host:Expect the host's mirror in the list, and a successful pull.
Automated Testing Overview
Claude Code ran markdownlint with
.markdownlint.jsoncon the changed page, which passed. Nobody ran the strict Zensical build locally, so CI's docs check covers it. Claude Code checked the configuration itself on both hosts: each mirror timed out from the other host, and a workspace on each host still found its mirror and pulled through it.Release/Deployment Notes
coder.ddev.com and staging-coder.ddev.com already use this configuration. Other self-hosted installs should apply the unit change and the firewall rule from Step 3.
🤖 Developed with assistance from Claude Code
https://claude.ai/code/session_01T3Cc2G6867sD8ZdDCVZ7Em