Skip to content

fix(origin): serve port 80 instead of redirecting to a certificate nobody can verify - #14

Merged
ralyodio merged 1 commit into
mainfrom
fix/no-redirect-stock-clients
Aug 3, 2026
Merged

fix(origin): serve port 80 instead of redirecting to a certificate nobody can verify#14
ralyodio merged 1 commit into
mainfrom
fix/no-redirect-stock-clients

Conversation

@ralyodio

@ralyodio ralyodio commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This changes a line the template explicitly says to keep, so here is the argument.

The existing comment

# Keep this. Upgrading to HTTPS is right, and it was only ever a problem
# when there was no 443 block for the name to land on ...
return 301 https://$host$request_uri;

The premise is that a 443 block makes the redirect safe. It does not, because it assumes the client can verify what it lands on.

Why stock clients cannot

No CA will issue for an ending outside the DNS root, so the 443 block presents a self-signed certificate. That is fine for TronBrowser, moshpit-proxy and the SDKs — they check it against the registry's published pin, which is a stronger statement than a CA's. It is fatal for everyone else:

curl chovy.hacker -L
curl: (60) SSL certificate problem: self-signed certificate

Through the gateway it is worse: pit.moshcode.sh forwards the status without the Location header, so a visitor gets a 301 pointing nowhere at all.

Both were reproduced on a live origin today.

The change

Port 80 serves the site. Both ports serve it, neither redirects to the other, and each client takes the one it can verify — pin-checking clients still get TLS, everyone else gets the page instead of an error that reads as "Moshpit is broken".

HTTPS-only is still right for a name in the public DNS. It is not available for a name outside it, and pretending otherwise costs the visitor the site.

Verified

Rendered with a real name and run through nginx -t: syntax is ok.

Why it matters more than one template

moshpit-reconcile.sh runs this every 60s for every name pointed at a box, so this redirect is applied automatically to every Moshpit origin — and re-applied after anyone fixes a vhost by hand.

…body can verify

The template redirected :80 to :443, with a comment saying the only
problem was a missing 443 block. That reasoning was incomplete: it
assumes the client can verify what it lands on, and the two biggest
classes cannot.

No CA will issue for an ending outside the DNS root, so the 443 block
presents a self-signed certificate. TronBrowser, moshpit-proxy and the
SDKs check it against the registry's published pin and are fine. curl and
a stock browser have no pin to check, so they reject it — and the
redirect leaves them nowhere:

    curl chovy.hacker -L
    curl: (60) SSL certificate problem: self-signed certificate

Through the gateway it is worse: pit.moshcode.sh forwards the status and
not the Location, so a visitor gets a 301 pointing nowhere at all.

Now :80 serves the site. Both ports serve it, neither redirects to the
other, and each client takes the one it can verify — pin-checking clients
still get TLS, everyone else gets the page instead of an error that reads
as "Moshpit is broken".

HTTPS-only remains right for a name in the public DNS. It is not
available for a name outside it, and pretending otherwise costs the
visitor the site.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@ralyodio
ralyodio merged commit f790d49 into main Aug 3, 2026
3 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.

1 participant