Skip to content

deploy: modular nginx site files on sysweb1's shared host layer - #34

Merged
hali-coding merged 2 commits into
mainfrom
feat/nginx-modular
Nov 14, 2026
Merged

hali-coding merged 2 commits into
mainfrom
feat/nginx-modular

Conversation

@hali-coding

@hali-coding hali-coding commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

What

sysweb1 now has a shared host layer for nginx, laid out the way Ubuntu lays out its own files. Each site file is now about 20 lines of includes, where it used to be 83 lines that were mostly copies of each other. This PR brings BeanWeb's two site files in line with that layer. Both files are already installed on sysweb1 and are byte-identical to the versions here.

The host layer, in /etc/nginx on sysweb1. It is maintained outside this repo; deploy/README.md describes it.

File What it does
sites-available/catch-all The only default_server. On port 80 it serves every hostname: it answers Let's Encrypt challenges, then redirects to https. On 443 it refuses the TLS handshake for any name without a site file, so no certificate or hostname leaks.
snippets/https.conf The 443 listeners, http2, Let's Encrypt challenges on 443, and server_tokens off.
snippets/cloudflare.conf Real visitor IPs plus the origin lock: anything not from Cloudflare or the box itself is closed with 444, so it gets no status, headers or page.
snippets/static-spa.conf and snippets/static.conf Serving and cache headers for single-page apps and for plain static sites.
snippets/proxy.conf Headers, HTTP/1.1 and WebSocket upgrade for proxying to a container.
conf.d/sysweb1.conf The vhost log format (hostname first, plus backend timing), gzip types, the TLS session cache, and the upgrade map.

nginx.conf and the package's default site are not edited, because both belong to the nginx-common package. default is only disabled, which is what its own header comment recommends.

Changes in this repo:

  • deploy/nginx/beanweb.halicode.com and beanweb-test.halicode.com (renamed from beanweb.conf and beanweb-test.conf). Each is one 443 server block with no port-80 block, since the catch-all handles port 80.
  • deploy/README.md documents the host layer and the new certificate and install steps. coffeeshop/README.md shows the proxy block using snippets/proxy.conf.

Testing

  • Rehearsal: I rebuilt the whole tree in an nginx container using the server's own nginx.conf and Cloudflare range files. Results:
    • SPA routes return 200 and a missing asset returns 404.
    • Cache headers are correct, and the proxy reaches the backend.
    • Port 80 redirects to https, and challenges are served for any hostname.
    • Unknown or missing SNI on 443 is refused ("unrecognized name").
    • A non-Cloudflare client gets an empty reply.
  • Rollout on sysweb1: three steps (host layer, then test, then prod), each backed up first with automatic restore if nginx -t failed. Both sites stayed at 200/301/200 after every step.
  • Checks afterwards:
    • nginx -t shows no warnings.
    • The origin reveals nothing to direct hits. By IP or by sysweb1.halicode.com, port 80 closes the connection with no reply, and 443 refuses the TLS handshake without showing a certificate. Through Cloudflare, error pages say only nginx, with no version or OS.
      • The one thing a direct hit can still get is a site's certificate, and only by asking for that site's name. A server cannot withhold its certificate from a client that requests it by name.
    • Challenges reach the server through Cloudflare for both hostnames.
    • certbot renew --dry-run succeeds for both certificates; the real Let's Encrypt validation came in through the catch-all.
    • All 10 files on the server match their sources.

🤖 Generated with Claude Code

sysweb1 now has a host layer in Ubuntu's own layout -- snippets/https.conf,
cloudflare.conf, static-spa.conf, proxy.conf, conf.d/sysweb1.conf and a
catch-all site that is the only default_server (port 80 for every name:
ACME + redirect; 443 for unknown names: handshake refused). nginx.conf and
the package's default site are untouched; default is only disabled.

So each BeanWeb site file is one 443 server block of includes, named after
its hostname (deploy/nginx/beanweb.halicode.com, beanweb-test.halicode.com),
with no port-80 block. Both are installed on sysweb1 and byte-identical to
these files. deploy/README.md documents the host layer they depend on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 14, 2026 13:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

TLS, origin enforcement, routing, caching, and rollback depend on host-only configuration and scripts absent from the checkout, requiring maintainer verification of the composed configuration and reported rollout checks.

No open issues 🎉

What changed in this PR

Aligns BeanWeb’s production and test nginx site files with sysweb1’s externally maintained shared host layer, removing duplicated configuration while retaining site-specific settings.

Changes:

  • Replaces the .conf files with hostname-named HTTPS configurations using shared snippets.
  • Delegates port-80 redirects and certificate challenges to the host’s catch-all site.
  • Updates deployment instructions and the Coffee Shop proxy example.
File Description
deploy/​README.md Documents host dependencies, certificate issuance, and site installation.
deploy/​nginx/​beanweb.halicode.com Adds the modular production HTTPS configuration.
deploy/​nginx/​beanweb.conf Removes the superseded production configuration.
deploy/​nginx/​beanweb-test.halicode.com Adds the modular test HTTPS configuration.
deploy/​nginx/​beanweb-test.conf Removes the superseded test configuration.
coffeeshop/​README.md Updates site paths and demonstrates the shared proxy snippet.

Review effort: Balanced

The host layer now closes non-Cloudflare connections with 444 (no status,
headers or page) instead of a 403 that named nginx's version and OS, and
sets server_tokens off per server block. By IP or by sysweb1's own name the
box answers nothing on 80 and refuses the TLS handshake on 443.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hali-coding
hali-coding merged commit a44a2c2 into main Nov 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants