Skip to content

Mailroom ACME mode should also serve plain HTTP on :80 #1953

Open

Description

@DanGould

When [acme] is configured, payjoin-mailroom binds a single listener (normally [::]:443) and serves only TLS. Certificates come from TLS-ALPN-01, so nothing ever listens on :80.

That shuts out clients that can't speak TLS. Bitcoin Core is the main one. These clients don't need TLS to use a mailroom safely, because OHTTP and the key bootstrap already protect the payload. Today an operator who wants to serve them has to drop ACME and put the plain build behind nginx with certbot, which is the setup ACME was meant to replace.

From my comment on #1315:

I realize payjoin-service still only listens on one port, when in reality it should probably listen on :443 with acme and :80 without it so that environments without TLS, e.g. Bitcoin Core, can still reach the directory while relying on bootstrap mechanisms other than TLS.

Originally posted by @DanGould in #1315 (comment)

Part of #941

Activity

  1. DanGould commented on Oct 9, 2026

    @DanGould
    MemberAuthor
  2. yahia008 commented on Oct 9, 2026

    @yahia008

    Hi, I'd like to work on this. Here's my plan. Does it sound right before I start?

    Approach

    • Add an optional plain-HTTP listener to the ACME config (e.g. http_listener = "[::]:80" under [acme], also settable via PJ_ACME__HTTP_LISTENER).
    • In serve_acme, build Services / the Router once and serve the same app on both listeners:
      • TLS on listener through the existing ACME acceptor
      • plain HTTP on http_listener through tokio_listener with sleep_on_errors = true, as serve does
    • Run both servers in a single tokio::select! with shutdown_signal(), so SIGTERM stops both and flush_windows() still runs once.
    • Port 80 serves the full app with no redirect to HTTPS, since the whole point is to reach clients that can't follow one. ACME is unaffected because TLS-ALPN-01 stays on 443.

    Things I'll keep working

    • Access control: the plain listener provides ConnectInfo so check_geoip applies on :80 too, keeping the Enforce mailroom access control on TLS serve paths #1941 fix intact.
    • One shared app instance means one FilesDb and one sentinel tag. Mailboxes are shared across ports and self-loop detection still works.
    • Fail at startup if :80 can't be bound, instead of silently running TLS-only.

    Also updating: config.example.toml, docker-compose.yml (80:80), the Nix module example, the mailroom README, and the CHANGELOG.

    Tests

    • Factor the "serve app on TLS + optional plain listener" part so it can be tested with a self-signed cert like serve_manual_tls.
    • Check /health over both ports.
    • Post to a mailbox on one port and read it on the other.
    • Check that blocked IPs get 403 on :80.
    • Check that the config parses.
    • Manually, I can try Let's Encrypt staging and the Bitcoin Core feat/async-payjoin branch you mentioned.

    Questions

    1. Should ACME mode bind :80 by default, or only when http_listener is set?
    2. Should the setting go under [acme] or at the top level, so manual-TLS setups could reuse it later?

    AI disclosure: I used an AI assistant to help research the codebase and draft this comment. I've reviewed the plan and will write and understand the changes myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions