Repository navigation
Serve the game over HTTPS behind Caddy, harden the server, and gather the deployment docs - #57
Merged
Merged
Conversation
…ind a proxy Three pieces in web-common, which the bitmap server now applies, for a server on the internet: - The same-origin check refuses, with 403, any POST and the game's WebSocket handshake that another site's page sends. The page must come from the public URL or, for other names such as a LAN address, from the Host the request was sent to. - After 10 failed logins from one client within 15 minutes, its logins are refused with 429 and Retry-After until 15 minutes after the first. A successful login clears the count. - RYLWEEN_TRUSTED_PROXIES (or --trusted-proxies) names the reverse proxies whose X-Forwarded-For is believed. The client is the nearest hop that is not one, never looked up in DNS, and every request and failed login logs it as client=.
…/deploy.sh --https compose.https.yaml runs the released image behind Caddy, which gets and renews a Let's Encrypt certificate for RYLWEEN_DOMAIN, redirects HTTP to HTTPS, and adds HSTS, nosniff, and no-referrer. The game publishes no port; it gets secure cookies, its public URL, and Caddy's network as the trusted proxies. ./deploy.sh --https pulls the latest release, starts it, waits up to three minutes for a valid certificate, and prints the address and the commands to manage it. Each release attaches a compose.https.yaml pinned to its image, and the release notes point to the guide.
deploy/README.md is now the one guide to running the game as a server: which way to choose, what deploy/ holds, the local network over HTTP, and, step by step, the internet over HTTPS, from what the machine needs (a public address, a domain name, ports 80 and 443) to upgrades, backups, what it protects, and troubleshooting. It takes in deploy/docker/README.md, the deploy script's section of the bitmap runtime's README, and the production and router notes of the ANSI web runtime's README, which now link to it. The root README points newcomers at playing, hosting, changing the game, and the code, and at the terminal zip in each release.
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.
What
You can now put the bitmap game on the internet over HTTPS. A machine with Docker or Podman, a public address and a domain name needs one compose file and a
.env; Caddy obtains and renews the certificate. The game server also gets the protections a public server needs. All deployment docs now live in one guide,deploy/README.md.Commits
Refuse cross-site requests, limit failed logins, and know clients behind a proxy. Adds three pieces to
web-common, which the bitmap server applies:/ws/playhandshake, sent by another site's page is refused with 403. A request passes when it comes from the public URL, or, for other names such as a LAN address, from theHostthe request was sent to.Retry-After. The block ends 15 minutes after the first failure, and a successful login clears the count.RYLWEEN_TRUSTED_PROXIES(or--trusted-proxies) lists the proxies whoseX-Forwarded-Foris believed. The client is the nearest hop that isn't one of them, and it is never looked up in DNS. Requests and failed logins log it asclient=.Serve the game over HTTPS behind Caddy, with compose.https.yaml and ./deploy.sh --https.
deploy/compose.https.yamlruns the released image behind Caddy:RYLWEEN_DOMAIN, redirects HTTP to HTTPS, and adds HSTS, nosniff and no-referrer headers.reverse-proxycommand, so there's no Caddyfile to manage../deploy.sh --httpspulls the latest release and starts it. It then waits up to three minutes for a valid certificate and prints the address and the commands to manage it.compose.https.yamlpinned to their image, and the release notes link to the guide.Plain HTTP stays the default everywhere.
Gather the deployment docs in deploy/README.md. One guide covers:
deploy/holds;It absorbs:
deploy/docker/README.md;Those places now link to it. The root README gains one orientation line (play, host, change the game, code) and a pointer to the terminal zip in each release.
Testing
Retry-After: 899.X-Forwarded-Forfrom an untrusted peer is ignored. Behind a trusted proxy, clients are counted and logged apart.localhost, on high ports, since rootless Podman won't bind 80 and 443:compose.https.yamlpins only the image../deploy.sh --httpswithoutRYLWEEN_DOMAINexplains what to set, and it reads the name fromdeploy/.env, quoted or not.Not tested yet: a real Let's Encrypt certificate on a public machine.
Found in testing, and documented in step 9 of the guide: rootless Podman (and Docker's userland proxy) hide players' addresses from Caddy. Every player then counts as one client for the login limit. Rootful Docker on Linux keeps the real addresses.