-
Notifications
You must be signed in to change notification settings - Fork 0
GitHub Pages and DNS
This page documents how the project's own marketing/landing page is hosted
and wired up - useful context for future maintainers, and a template if you
ever want to do the same for a fork or white-labeled deployment. This is
unrelated to the Custom Domain Setup for the
deployed API (app.nmailx.com in that example) - that's your /send and
/admin endpoints; this page is about the project's static landing page.
- Source lives in
docs/index.html(plusdocs/CNAME) on themainbranch of the repo - a single, hand-written, dependency-free HTML/CSS page (no CDN, no framework, no build step), consistent with this project's general preference for vendoring or hand-rolling its own frontend assets rather than depending on a CDN (see Vendored Assets). - GitHub Pages is configured to deploy from
main, folder/docs, using GitHub's built-in "Deploy from a branch" source (not a custom Actions workflow) - the simplest option, since GitHub Pages' branch-deploy source only supports the repo root or a folder literally named/docs(not an arbitrary folder name). -
docs/CNAMEcontainswww.nmailx.com- GitHub Pages reads this file to configure the custom domain automatically.
GitHub Pages' built-in branch-deploy source can only point at the repo root
or a folder named exactly /docs. A custom folder name (e.g. /site)
would require switching to an Actions-based deploy
(actions/upload-pages-artifact + actions/deploy-pages), which adds a
workflow and a build step for no real benefit here, since the page has no
build process to begin with. /docs was chosen to keep things simple.
nmailx.com's DNS is managed in Cloudflare, same as the domains this
project sends email from. Two records/rules make www.nmailx.com work and
send the bare apex to it:
-
wwwCNAME ->napalm255.github.io, set to DNS-only (grey cloud), not proxied. This matches the project's existing convention for DNS-only records (see the DKIM and custom-domain CNAMEs in Custom Domain Setup) - a proxied record would interfere with GitHub's automatic TLS certificate issuance and custom domain verification for Pages. -
Apex redirect - a Cloudflare Redirect Rule (Rules -> Redirect Rules)
that matches requests to the bare
nmailx.comhostname and redirects them (301) to the equivalent path onhttps://www.nmailx.com. This keepswww.nmailx.comas the single canonical hostname rather than trying to serve Pages directly from the apex (GitHub Pages' apex support requiresA/AAAArecords to GitHub's IPs, which is more fragile to keep in sync than a redirect rule).
GitHub can only issue/validate the TLS certificate for the custom domain
once the CNAME above has propagated and GitHub's own domain verification
succeeds. After that, enable "Enforce HTTPS" in the repo's Pages settings
(Settings -> Pages) so http://www.nmailx.com redirects to https://.
# Pages build/config status
gh api repos/napalm255/nmailx/pages --jq '{html_url, cname, status, https_enforced}'
# Once DNS has propagated
curl -I https://www.nmailx.com # expect 200 from GitHub Pages
curl -I https://nmailx.com # expect a redirect to https://www.nmailx.com