Choose a TLS mode
Choose off behind a TLS proxy, local for development, files for an existing certificate or letsencrypt for automatic issuance and renewal.
Choose one mode below. Save its profile as m4w.json, start the server and run the test in a second terminal. Stop the server before trying another mode.
php vendor/mini4work/webserver/examples/server.php m4w.jsonoff
If a reverse proxy such as Nginx or Traefik handles HTTPS and forwards plain HTTP to Mini4Work on the same host, keep the backend on loopback. Test the backend with HTTP and the public hostname with HTTPS.
{
"listen": { "port": 9000 },
"tls": { "mode": "off" }
}curl -i http://127.0.0.1:9000/local
Save this as m4w.json in the application root. It creates development certificates in var/tls. The client will trust the public CA explicitly for its request.
{
"listen": { "port": 9000 },
"tls": {
"mode": "local",
"storage": "var/tls",
"local": { "trust_ca": "off" }
}
}In another terminal, replace the CA path below with the public certificate path from the server’s tls.trust.root event.
CA=/path/from/tls.trust.root
curl --cacert "$CA" -i https://localhost:9000/files
Next to vendor/, create a certs/ directory. Place the PEM certificate chain, leaf first, in certs/fullchain.pem and its matching private key in certs/privkey.pem. Give the server account read access and keep the key outside public asset directories.
{
"listen": { "port": 9000 },
"tls": {
"mode": "files",
"files": {
"certificate": "certs/fullchain.pem",
"private_key": "certs/privkey.pem"
}
}
}Replace app.example.com with the name on your certificate. Run this on the server machine. The request connects locally while curl verifies the certificate for that hostname.
curl --resolve app.example.com:9000:127.0.0.1 -i https://app.example.com:9000/letsencrypt
Use your public DNS name and contact email below. Forward public TCP 80 to port 9080 for HTTP-01 and TCP 443 to port 9000 for HTTPS. Enable the PHP curl and openssl extensions.
{
"listen": { "port": 9000 },
"tls": {
"mode": "letsencrypt",
"storage": "var/tls",
"acme": {
"domains": ["app.example.com"],
"email": "[email protected]",
"environment": "staging",
"port": 9080
}
}
}These ports listen on loopback by default. Use a local proxy or set listen.host to an address reachable by your port forwarder. Once staging issuance succeeds, change staging to production, restart and test the public URL.
curl -i https://app.example.com/tls.storage defaults to ../var/tls. Keep this private directory persistent across deployments for managed certificate and account material. tls.renew_before_days defaults to provider policy. An explicit value from 1 to 365 chooses the renewal window.