Configuration
Command Line Options
| Option | Description |
|---|---|
-h, --help |
Show help message |
-v, --version |
Show version |
-d, --daemon |
Run as daemon |
-c, --config=PATH |
Config directory (default: .) |
-r, --runtime=PATH |
Runtime directory for pid/log (default: .) |
-u, --user=USER |
Run as specified user |
-g, --group=GROUP |
Run as specified group |
--error-log=PATH |
Error log file (default: ) |
--access-log=PATH |
Access log file |
config.json
The config directory must contain a config.json file:
{
"http": "0.0.0.0:8080"
}
| Field | Description |
|---|---|
http |
HTTP listen address |
https |
HTTPS listen address |
acme |
ACME configuration for automatic certificates |
app |
JavaScript app file (default: app.js) |
acme.cacheDir |
(Optional) Directory to store ACME certs/account. Defaults to . Use a writable path when running as non-root. |
At least one of http or https must be specified.
HTTPS with ACME
JSRealm supports automatic SSL certificates via ACME (Let's Encrypt).
{
"http": "0.0.0.0:80",
"https": "0.0.0.0:443",
"acme": {
"directory": "https://acme-v02.api.letsencrypt.org/directory",
"email": "admin@example.com",
"domains": ["example.com", "www.example.com"]
}
}
| Field | Description |
|---|---|
acme.directory |
ACME directory URL |
acme.email |
Account email for notifications |
acme.domains |
List of domains for the certificate |
How it works
1. On startup, JSRealm checks for cached certificates in
2. If valid certificates exist, HTTPS starts immediately
3. If not, certificates are requested via ACME HTTP-01 challenge
4. Certificates are automatically renewed 30 days before expiry
Requirements
- Port 80 must be accessible for HTTP-01 validation
- Domains must resolve to this server
- Firewall must allow inbound 80 and 443
Staging
For testing, use the Let's Encrypt staging environment:
{
"acme": {
"directory": "https://acme-staging-v02.api.letsencrypt.org/directory",
"email": "admin@example.com",
"domains": ["example.com"]
}
}
Certificate storage
Certificates are cached in :
<config_dir>/
├── config.json
├── app.js
└── acme/
├── cert.pem
├── key.pem
└── account.json
Signals
| Signal | Action |
|---|---|
| SIGTERM, SIGINT, SIGQUIT | Graceful shutdown |
| SIGUSR1 | Reopen log files |