From nginx -t to a running origin: controlled Nginx startup through the CLI

A separate drop-in, an owned-mask move and explicit start. Checking the actual worker, loopback socket and HTTP while retaining incomplete-operation evidence.

A lever controls a server module while a connected inspection unit and lamp show the startup result.

A validated configuration does not yet mean the web server is running. In the preceding step, the CLI wrote a separate Nginx main file and checked its syntax in isolation. The service remained inactive. The next operation must authorize the start separately and verify processes, the socket and HTTP.

We added activation-plan, activation-apply and activation-verify for this purpose. Their scope is a static origin on IPv4 loopback in a disposable Debian 13 VM. PHP-FPM and a public domain belong to later stages.

The history of earlier changes comes first

The new plan relies on the original layout, firewall, package installation and startup-disable approvals. It also takes the exact main-configuration plan bytes and the digest of its committed journal. A file with the expected name does not establish its provenance.

The original documents stay private. The CLI checks the machine, SSH profile, selected key, trusted host key, configuration and current independent-console evidence. Changed inputs require another review; there is no arbitrary switch to skip verification.

What activation changes

The main file is already installed. This operation creates a new systemd drop-in with commands for that file, moves its owned mask into a private journal, performs daemon-reload and issues one explicit start. The mask moves through a no-replace rename. Foreign files at either destination stop the operation.

This is an excerpt from our implemented drop-in. It is not a complete service configuration: the same file also sets the dependency on the owned firewall service and exact reload and stop commands.

[Service]
ExecStartPre=
ExecStartPre=/usr/sbin/nginx -t -q -c /etc/nginx/deploy-cli-origin.conf
ExecStart=
ExecStart=/usr/sbin/nginx -c /etc/nginx/deploy-cli-origin.conf

The empty assignments clear the preceding commands for these properties, so startup uses our main configuration. After systemd reads the unit again, the CLI separately checks the effective ExecStartPre, ExecStart, ExecReload, ExecStop, PIDFile and firewall ordering.

During this explicit startup, the unit runs its own ordinary nginx-t on the host. It belongs to the authorized start operation, including its runtime files. This differs from the earlier isolated syntax check, where we required the host PID, log and temporary paths to remain unchanged.

A plan and explicit execution

This adapted example assumes a prepared private profile. Replace angle-bracket values with the exact digests of your approved documents. Copying the example alone does not prepare its dependencies.

deploy-cli host nginx activation-plan --profile demo \
  --request-file /private/administrator-current.json \
  --nginx-file /private/nginx.json \
  --dependencies-file /private/nginx-dependencies.json \
  --configuration-plan-file /private/configuration.json \
  --configuration-plan-sha256 <CONFIG_PLAN_SHA256> \
  --configuration-manifest-sha256 <CONFIG_MANIFEST_SHA256> \
  --plan-file /private/activation.json

The plan is saved as a new private file with mode 0600. activation-apply requires the same references, the exact SHA of this new plan and --approve-privileges. After execution, the CLI opens a separate SSH connection to verify the committed result. activation-verify reads the result without permission to change managed files.

Why active alone is insufficient

The systemctl documentation treats the current service state and startup enablement separately. Our verifier additionally reads the actual master process, its child worker and executable through procfs.

ObjectOur verification requirement
MasterRoot, the expected executable and exact configuration path
WorkerOne child process; UID, GID and supplementary groups match the verified web identity
PID fileOwned by root, mode 0644, containing the current master PID
SocketOne TCP listener on 127.0.0.1 and the approved port, associated with these processes
HTTPReal loopback requests checking the expected denials

The master/worker split follows the Nginx process model. Our implementation checks the particular UID, groups, PID and socket on the current machine. It pairs the PID with process start time because the kernel can reuse the number.

What the actual VM verification showed

On a fresh Debian VM, activation-apply completed four steps and obtained confirmation over a new SSH connection. A repeated apply read the same committed journal without starting Nginx again. This is the reduced actual response from another separate activation-verify; private references and digests are omitted:

{
  "mode": "host-nginx-activation-verify",
  "status": "passed",
  "write_performed": false,
  "write_state": "none",
  "action": "activation-verify",
  "access_verified": true
}

The public verifier issued HTTP denial controls. Additional requests from the native fixture checked the exact probe-file bytes in each public root and the denied paths. These are static dummy files, not requests to PHP or real private data.

VM requestStatus
GET frontend.example.test /sample.txt200
GET admin.example.test /sample.txt200
GET for a missing file, dotfile, probe.php or symlink404
POST to a known virtual host403
GET with an unknown Host404
GET with invalid Host: bad host400
Genuine terminal frame: systemctl, ps, ss and fresh VM HTTP requests. Two public roots serve probe files; denial controls are shown separately. Startup remains disabled.

Starting in this boot and enabling startup are separate operations

This step keeps startup disabled. The package policy for Nginx also remains. Successful running-service verification belongs to the approved boot; after a reboot, old evidence cannot establish a new master or worker. This operation includes no automatic start after reboot.

The preceding verifiers retain their original requirements. For example, ordinary guard-verify must no longer report that the mask remains at its old path after the controlled move. The new transition owner checks original provenance together with its own committed changes.

Handling an unknown result

The first native run produced a useful refusal before start. Debian returned two separate ExecReload lines, while our parser incorrectly required one line per property. The mask had already moved and systemd had read the unit again. Independent journal readback showed three completed steps and an inactive service with PID 0; verification refused the pending state without writes. We fixed the parser, added a test of the actual format and shut that VM down normally. We did not resume its incomplete apply.

The journal enters pending before the drop-in is created. If a write or start has begun but its response is lost, there is no second start or automatic cleanup. The journal and actual state must be read through independent access. Separate temporary-file tests reproduce a lost result after actual file creation and a modelled service start.

This boundary matters for the next technologies: automation must know what finished, which processes actually run and which state is still unproven. Otherwise a single “configure server” command would conceal unfinished steps.

We then performed a separate normal VM reboot. The service remained disabled/inactive with PID 0, while its owned persistent files remained exact. Old activation-verify refused the boot mismatch without writes. This refusal confirms the proof boundary; it is not a successful startup-after-reboot result.

  1. Operations & Security ACLs on Debian: allow public files and protect the private tree
  2. Architecture Debian service users: a separate identity for each application
  3. Architecture Nginx on Debian: two public roots and HTTP access checks
  4. Operations & Security Startup and reboot: firewall, ready FPM, then Nginx
  5. Architecture Why Nginx before PHP-FPM: preparing a server for several applications
  6. Operations & Security Why nginx -t needs isolation: testing configuration without changing the host