CLI HTTPS with a Cloudflare firewall: installation and rollback
Installing HTTPS over an accepted Cloudflare policy: an exact firewall plan, distinct boot evidence, verification, replay without another reload and owned-file rollback.
Once Cloudflare web traffic is allowed, the server has a different network policy. SSH remains a separate management channel, while TCP ports 80 and 443 accept only the approved sources. A first HTTPS installation through CLI needs to recognise that prerequisite explicitly.
Why the base firewall check is insufficient
The closed mode expects no web ingress. WireGuard has its own accepted policy. When a Cloudflare-only origin policy is already installed, substituting the original base check either rejects the real state or conceals a policy change. The installed Cloudflare state needs an explicit selection.
That selection binds the management policy to a particular accepted plan, loader code and evidence from the current operating-system boot. An nftables table name alone does not establish that its permissions are correct.
Checks before installing certificate material
sudo nft --json list ruleset
sudo nginx -t
sudo systemctl show nginx --property=MainPID
These commands show the rules, syntax and current Nginx master process. They help the operator, but do not replace file and journal ownership checks. Automation also checks the exact firewall plan, accepted profile, committed installation and current evidence for accepted rules, distinguishing same-boot adoption from loader execution.
The allowed IPv4 ranges come from Cloudflare's official source. This restricts the source of connections to the origin; it does not by itself restrict them to one Cloudflare account or zone.
The check must remain valid throughout the operation
State can change between planning and configuration writes. The check therefore holds the firewall owner's locks while TLS work takes place. It reads the state again before side effects and after reload. A changed plan, incomplete operation, foreign rule or stale boot receipt must cause refusal.
After the locks are released, a retained reader must refuse before accessing server state. Otherwise its result could be reused outside the operation for which the authority was acquired.
Origin TLS and browser HTTPS are separate checks
An origin certificate protects the connection from Cloudflare to the server. It differs from the edge certificate presented to a browser. See Cloudflare's Origin CA documentation for Origin CA and Full (strict).
A local check with a separate fixture CA establishes the installed configuration, password and SNI behaviour within that fixture. It does not prove provider issuance or reachability through Cloudflare's public network. Those require separate evidence.
A practical run on a separate Debian VM
I tested this step on a new Debian disk. The firewall was configured manually; its base policy was checked after a real reboot through an independent console. Cloudflare permissions were added during the resulting OS boot. These are distinct stages: accepting new rules in the current boot does not replace checking their startup after another reboot.
The CLI installed PHP-FPM, the minimal extensions and the official Symfony skeleton. Installation journals from another server were never transferred. HTTPS used a separate test CA and newly generated fixture keys.
The planning command explicitly selects the installed Cloudflare policy. In this example, the PRIVATE_APP_FLAGS array holds the previously prepared SSH options, application profile and lower-role references. The other variables are paths to the operator’s private files. This illustrates command composition; it is not a ready set of credentials.
deploy-cli host application https-install-plan \
"${PRIVATE_APP_FLAGS[@]}" \
--application-reference "$PRIVATE_APP_REFERENCE" \
--https-file "$HTTPS_PROFILE" \
--firewall-file "$BASE_FIREWALL" \
--cloudflare-firewall-file "$CF_FIREWALL_REFERENCE" \
--plan-file "$TLS_PLAN"
After plan review, apply created the TLS directory, certificate, private key, BasicAuth file and one Nginx fragment. Syntax was checked before the single reload. A fresh SSH connection confirmed eight local HTTP checks and rejection of incorrect SNI. The checks covered authentication, page behavior, caching and indexing restrictions.
Replaying the same apply created no new records and performed no additional reload. All 61 selected configuration and journal files remained unchanged. A separate rollback removed the four owned TLS files and their empty directory; 57 previous files remained exact, with only a separate rollback journal added. Replaying rollback also changed nothing.
Two deliberate refusals were tested before installation: omitting the explicit Cloudflare selection and changing the accepted plan fingerprint. Both stopped without writing the role. Firewall rules, the application, the Nginx master process and PHP-FPM remained intact throughout the HTTPS lifecycle.
Replay and rollback also require ownership
Replaying a committed plan verifies the existing role without another reload. Rollback removes only files with exact creation provenance from that installer and requires the same firewall edition. Similar manually created files provide no deletion authority.
An interrupted operation is a different state. Ordinary apply must not silently complete its journal or repeat a reload with an unknown outcome. It requires a separate comparison between actual state and the last durable step.