9 config.json Reference
vBlackOut edited this page 2026-08-26 07:48:04 +02:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

config.json Reference

This page documents every option supported in ProxyAuth's config.json. It does not cover routes.yml (per-route/backend configuration) — see the separate routing guide for that.

config.json is read once at startup. With the exception of the otpkey field on each user (see TOTP (2FA) Enrollment & Reset — Admin Guide), changes to this file require a service restart to take effect.


Minimal example

{
  "token_expiry_seconds": 3600,
  "secret": "a-very-long-random-string-at-least-64-characters-please",
  "log": { "type": "local" },
  "users": [
    { "username": "admin", "password": "changeme" }
  ]
}

Only token_expiry_seconds, secret, log, and users are required — everything else has a default.


Core / required fields

Key Type Default Description
token_expiry_seconds integer (required) How long an issued session token stays valid, in seconds.
secret string (required) The master secret used to derive encryption/signing keys for tokens (via HKDF) and CSRF signatures. Must be long and random — 64+ characters recommended. Anyone with this value can forge valid tokens. Never commit it to source control.
users array of User objects (required) The list of accounts allowed to authenticate. Can be combined with databases below — see Database-backed users.
log object {"type": "local", "write_max_logs": "1000"} Log transport — where lines are written. See Logging transport.
logging object (see below) Access log — line format and which requests produce one. Optional. See Access log.
compression object (disabled) Response compression. Optional, off by default. See Compression.

User object

Each entry in users looks like:

{
  "username": "alice",
  "password": "alice-password",
  "allow": ["192.168.1.0/24"],
  "roles": ["admin"],
  "groups": ["ops", "admins"],
  "email": [
    { "address": "alice@example.com", "primary": true },
    { "address": "alice-backup@example.com", "primary": false }
  ],
  "must_change_password": false
}
Key Type Required Description
username string yes Login name. Must be unique.
password string yes Plaintext on first load — ProxyAuth hashes it with Argon2 and rewrites the field in config.json on first startup. From then on this holds the Argon2 hash, not the plaintext password.
otpkey string no The user's TOTP secret (base32). Normally you don't set this by hand — it's populated by /adm/auth/totp/get on first enrollment. See TOTP (2FA) Enrollment & Reset — Admin Guide.
allow array of strings no IP addresses/CIDR ranges this user is allowed to authenticate from. Omit to allow from anywhere.
roles array of strings no Role names. Forwarded to the backend via the X-User-Roles header regardless, so it can make its own authorization decisions — and, since Group- and Role-Based Access Control, also usable directly by a route's roles list in routes.yml to gate access.
groups array of strings no Group memberships. Matched against a route's groups list in routes.yml — see Group- and Role-Based Access Control. Purely an access-control mechanism (unlike roles, nothing is forwarded to the backend for this — well, actually it is: X-Groups, same idea as X-User-Roles; see that page).
email array of objects no Email address(es) on file for this user — used to send a proxyauth reset-password link. Each entry is { "address": "...", "primary": true/false }. Exactly one should be primary: true; if more than one is (or none is), the first entry in the list wins. See Password Reset & First-Login Forced Change.
must_change_password boolean no, defaults to false If true, this user's next successful login redirects to page_change_password (with a fresh single-use token) instead of issuing a normal session. Meant for a temporary password an admin just set. Cleared automatically the moment the user successfully sets a new one.
anti_replay_secret string, or null no — auto-generated The account's HMAC signing secret for the anti-replay plugin, stored as ciphertext. You don't set this by hand: it's generated automatically the first time this account is seen with plugin_anti_replay: true, and emailed to it once. Leave unset/null.

Database-backed users (databases)

By default, every user lives in the users array above, hand-edited in config.json. If you're running more than one instance, that means keeping every instance's file in sync by hand. databases is an optional alternative (or complement): point every instance at the same PostgreSQL or MySQL/MariaDB database, and they all read and write the same user base.

Full detail — schema, sync model, connection lifecycle, deletion detection, the local fallback cache, CLI usage — lives on its own page: Database-Backed Users. This section is just the config field reference.

"databases": {
  "type": "postgres",
  "host": "127.0.0.1",
  "port": 5432,
  "db_name": "proxyauth",
  "user": "proxyauth",
  "password": "changeme",
  "connect_timeout_secs": 5,
  "refresh_interval_secs": 30,
  "incremental_window_secs": 300,
  "full_refresh_interval_secs": 300,
  "deleted_retention_secs": 86400,
  "purge_interval_secs": 3600
}
Sub-key Type Default Description
type string (required) "postgres" (also accepts "postgresql"/"pg") or "mysql" (also accepts "mariadb").
host string (required) Database host.
port integer 5432 for postgres, 3306 for mysql Database port. Omit to use the type-appropriate default.
db_name string (required) Database name.
user string "" Database connection username.
password string "" Database connection password (plaintext — see Secret handling).
connect_timeout_secs integer 5 How long a connection attempt is allowed to take before giving up, instead of hanging for however long the OS's default TCP timeout happens to be. See Database-Backed Users § Connection lifecycle for why this matters beyond just connection speed.
refresh_interval_secs integer 30 How often, in seconds, the incremental scan runs. Set to 0 to disable it.
incremental_window_secs integer 300 (5 min) The lookback window used by the incremental scan — "users changed in the last N seconds." Keep it at least as long as refresh_interval_secs, with some overlap.
full_refresh_interval_secs integer 300 (5 min) How often the full scan runs — reads the entire users table. Mainly a safety net for TRUNCATE TABLE users, which bypasses the deletion trigger entirely. Set to 0 to disable.
deleted_retention_secs integer 86400 (24h) How long a soft-deleted user (and its deletion-log entry) stays in the database before being permanently purged. Must be at least incremental_window_secs.
purge_interval_secs integer 3600 (hourly) How often the purge of expired soft-deletions/log entries runs. Safe to leave enabled on every instance.

Network / server

Key Type Default Description
host string or array of strings "0.0.0.0" Address(es) the server binds to. Accepts either a single string ("0.0.0.0", the original format — still fully supported) or an array (["0.0.0.0", "::1"]) to bind more than one at once, e.g. IPv4 and IPv6 together. Every entry gets its own listening socket, all served by the same server instance (one shared worker pool, not a separate process per address). IPv6 literals can be given bare ("::1") or pre-bracketed ("[::1]") — both work.
port integer 8080 Port the server listens on.
worker integer 4 Number of Actix worker threads.
num_instances integer 2 Number of server instances/processes.
socket_listen integer 1024 Listen backlog size for the TCP socket.
max_connections integer 50000 Maximum simultaneous connections.
pending_connections_limit integer 65535 Maximum queued/pending connections before new ones are rejected.
client_timeout integer (ms) 5000 Timeout for client connections.
keep_alive integer (ms) 5000 HTTP keep-alive timeout.
max_idle_per_host integer 50 Max idle pooled connections kept open per backend host.
max_body_size integer (bytes) 10485760 (10 MB) Maximum request body size accepted from clients.
tls boolean true Whether to terminate TLS. When true, ProxyAuth expects a certificate/key at /etc/proxyauth/certs/ (see the TLS guide).
run_user string "proxyauth" The system user the process drops privileges to after binding its listener(s) (which needs root for ports below 1024). An empty string ("") is treated the same as unset — falls back to proxyauth. Also respected by every CLI command that needs to run as the same user the server itself runs as (db-add-user, certbot renew, etc.) — those must themselves be launched as root, and switch to run_user automatically.
run_group string (unset) Group to run as instead of run_user's own primary group. Rarely needed — set this if the account you're using needs supplementary group membership (e.g. to read certificates owned by a different group) beyond what its own primary group provides.
timezone string "Europe/Paris" IANA timezone name used when formatting/checking token timestamps in logs and expiry logic.

Authentication & sessions

Most of these can now also be set per vhost, overriding this global default for just that vhost — see routes.yml Reference § Per-vhost behavior overrides. The fields below remain the fallback a vhost uses when it doesn't set its own.

Key Type Default Description
token_admin string "" Admin token, required in the X-Auth-Token header to call /adm/stats, /adm/logs, /adm/revoke, and /adm/auth/totp/reset. Treat this like a root credential — anyone with it can revoke sessions, read logs, and reset a user's 2FA.
login_via_otp boolean false If true, every login requires a valid TOTP code in addition to the password. Users must be enrolled first via /adm/auth/totp/get — see TOTP (2FA) Enrollment & Reset — Admin Guide.
fast boolean false Token verification mode. false (default, recommended) applies an extra hashing step for stronger security at some CPU cost; true skips it for lower latency at reduced security margin. Leave this false unless you specifically understand and accept the trade-off.
session_cookie boolean false If true, issue the session token as an HttpOnly/Secure/SameSite=Strict cookie (session_token) in addition to returning it in the JSON response.
max_age_session_cookie integer (seconds) 3600 Max-Age of the session cookie, when session_cookie is enabled.
csrf_token boolean true Enables CSRF protection (signed, single-use nonce) for cookie-based sessions. Only relevant when session_cookie is true.
plugin_anti_replay boolean false Enables the request-signing anti-replay plugin — verifies X-User/X-Timestamp/X-Nonce/X-Signature on proxied requests. Off by default. See Anti-Replay Protection.
anti_replay_window_secs integer (seconds) 60 Timestamp drift / nonce-replay tolerance window for the anti-replay plugin. Only relevant when plugin_anti_replay is true. See Anti-Replay Protection.
login_redirect_url string or null null If set, a successful cookie-based login redirects here instead of returning JSON. Must be a relative path starting with /.
logout_redirect_url string or null null If set, /logout redirects here after clearing the session.

Rate limiting

Key Type Default Description
ratelimit_auth object {"requests_per_second": 0, "burst": 1} Rate limit applied to /auth and /adm/auth/totp/get. requests_per_second: 0 effectively disables limiting.
ratelimit_proxy object {"requests_per_second": 0, "burst": 1} Rate limit applied to proxied requests.

Both objects accept the same two keys:

Sub-key Type Meaning
requests_per_second integer Sustained request rate allowed per rate-limit key (see below). 0 disables the limit.
burst integer Extra burst capacity above the sustained rate.

The rate-limit key is derived per-client from a trusted IP (see trust_proxy_forward_for below) combined with the authenticated user when available, and the request path — so limits apply per user/IP/route combination, not globally.

⚠️ /adm/revoke, /adm/logs, and /adm/auth/totp/reset are not covered by either rate limit — they're gated only by the admin token. Protect token_admin accordingly.


Reverse proxy trust

Key Type Default Description
trust_proxy_forward_for array of strings, or null null List of IPs/CIDR ranges allowed to set X-Forwarded-For/X-Real-Ip and have ProxyAuth trust them for client-IP resolution (used for rate limiting and access-control allow checks). Loopback is always trusted regardless of this setting. If you run ProxyAuth behind a load balancer or another reverse proxy, you must list its IP here — otherwise, either real client IPs are ignored, or (if you're not careful elsewhere) a client could spoof its own IP. Leave null if ProxyAuth receives traffic directly from the internet.

CORS

Can also be set per vhost — see routes.yml Reference § Per-vhost behavior overrides.

Key Type Default Description
cors_origins array of strings, or null null Allow-list of origins (e.g. "https://app.example.com") permitted to make cross-origin, credentialed requests to auth-related endpoints (/auth, /adm/auth/totp/get, /logout). Leave null to disable cross-origin access entirely.

Stats

Key Type Default Description
stats boolean false Enables the /adm/stats and /adm/stats/sessions endpoints (still gated behind token_admin). Tracks per-token usage counters in memory.

Logging transport (log)

log controls where log lines go — access-log lines and diagnostic warnings/errors alike. It does not control what a line contains or which requests produce one; that's logging below.

log is a free-form object; the fields ProxyAuth actually reads are:

Sub-key Type Default Description
type string "local" "local" stdout; "loki" ships to Grafana Loki (and stdout); "http" an in-memory buffer served by /adm/logs; "disabled" no output at all.
host string (required if type is "loki") Loki push URL, e.g. "http://loki:3100".
write_max_logs string (numeric) "1000" Buffer capacity for /adm/logs, used only when type is "http". Must be below 100000.

Example (Loki):

"log": {
  "type": "loki",
  "host": "http://loki.internal:3100",
  "write_max_logs": "2000"
}

"disabled" silences everything, including upstream failures, blocked IPs and path-traversal attempts. If you only want less per-request noise, use logging.enabled: false below instead — it keeps diagnostics.

See Logging for each mode in depth.


Access log (logging)

Optional. Controls the per-request log line: its format, and which requests get one. Produced by a middleware wrapped around the whole application, so it covers proxied routes, static routes, /auth, /adm/*, 404s, rate-limit rejections and framework errors alike.

"logging": {
  "enabled": true,
  "format": "[vhost] [ip] [method] [path] [status] [length] [user-agent] [x-forwarded-for]",
  "vhosts": {
    "internal.example.com": { "enabled": false }
  },
  "routes": {
    "/healthz": false,
    "/metrics": false
  },
  "resource_sample_interval_secs": 1
}
Sub-key Type Default Description
enabled boolean true Proxy-wide switch. Alias: log.
format string "[vhost] [ip] [method] [path] [status] [length] [user-agent] [x-forwarded-for]" Line format, as [placeholder] tokens mixed with literal text. Alias: format-log.
vhosts object {} Per-Host overrides. Unlisted hosts inherit enabled. Applies even to requests matching no route.
routes object {} Per-route overrides keyed by prefix. A route's own log: in routes.yml takes precedence.
resource_sample_interval_secs integer 1 Sampling interval for [cpu-usage]/[memory-usage]. No sampler runs unless the format uses one of them.

Placeholders: [vhost] [ip] [path] [method] [status] [length] [user-agent] [x-forwarded-for] [host] [protocol] [query] [referer] [request-time] [cpu-usage] [memory-usage] [username] [token-id] [route] [time].

An unrecognized placeholder is emitted verbatim, so a typo is visible rather than silently dropping a column.

Two fields that are easy to confuse: [ip] is the client address ProxyAuth actually acted on (trusted-proxy-aware, the same resolution the rate limiter and allow_ips/deny_ips use), while [x-forwarded-for] is the raw, spoofable header. [length] is the on-the-wire size, so it's the compressed size when compression applied.

Full details, including the five-level disable precedence: Logging.


Compression (compression)

Optional, and off by default — an existing config.json with no compression block behaves exactly as before.

"compression": {
  "enabled": true,
  "algorithm": "br, gzip, deflate",
  "level": 5,
  "min_size": 1024,
  "upstream_identity": true
}
Sub-key Type Default Description
enabled boolean false Master switch.
algorithm string "br, gzip, deflate" Preference order, most-preferred first. Single value or comma-separated. Filtered against the client's Accept-Encoding; the client's q-values win over this order.
level integer 5 Clamped per algorithm at use time (gzip/deflate 0–9, brotli 0–11), so one shared value is safe for all three.
min_size integer 1024 Responses smaller than this are sent uncompressed.
types array of strings (built-in list) Overrides the compressible media-type allow-list, matched as Content-Type prefixes. The always-excluded set (images, video, audio, woff/zip/gzip) still applies on top.
upstream_identity boolean true when enabled Rewrites the outgoing Accept-Encoding to identity so ProxyAuth compresses instead of the backend.
spawn_blocking_threshold integer 262144 Bodies at or above this size are compressed on the blocking thread pool rather than inline.

⚠️ upstream_identity is the field to check first if compression seems to do nothing. ProxyAuth relays the client's Accept-Encoding to the backend and copies its Content-Encoding back, so on a proxied route the backend normally compresses first — and the middleware then correctly refuses to re-encode an already-encoded body. upstream_identity: true (the default when enabled) asks the backend for a plain body instead, which is nginx's proxy_set_header Accept-Encoding "". Set it to false if your backend caches its compressed output.

Per-route and per-vhost-group overrides live in routes.yml — see routes.yml Reference. Full behaviour, including what is never compressed and the streaming caveat: HTTP Compression Support.


SMTP (optional)

smtp is optional; omit it entirely if you don't need email. It's used to send password-reset links — see Password Reset & First-Login Forced Change for the full flow. Can also be set per vhost — see routes.yml Reference § Per-vhost behavior overrides — for domains that need to send through a different mail server than this global default.

"smtp": {
  "host": "smtp.example.com",
  "port": 587,
  "username": "no-reply@example.com",
  "password": "smtp-password",
  "from": "ProxyAuth <no-reply@example.com>",
  "timeout_secs": 10
}
Sub-key Type Description
host string SMTP server hostname.
port integer SMTP server port. Controls which TLS mode is used, implicitly — 465 connects with TLS from the start (implicit TLS/SMTPS); any other port (587, 25, etc.) connects in plaintext and upgrades via STARTTLS. There's currently no way to override this heuristic explicitly.
username string SMTP auth username.
password string SMTP auth password (plaintext — see Secret handling below).
from string From: header used on outgoing mail.
timeout_secs integer Connection timeout, in seconds.

The email body template lives at /etc/proxyauth/mail/templates/reset_password.txt, created automatically with a sensible default on first startup if smtp is configured (never overwrites a template you've customized). First line is Subject = "..."; the rest is the body, with {{ username }} and {{ reset_link }} placeholders substituted at send time.


page_change_password (optional)

The URL a user's browser is sent to (with ?token=<reset_token> appended automatically) to set a new password — after proxyauth reset-password emails them a link, or automatically on their first login if their account has must_change_password: true. Required for either of those to work; both fail with a clear error if it's missing. Can also be set per vhost — see routes.yml Reference § Per-vhost behavior overrides.

"page_change_password": "https://example.com/change-password"

The page at that URL is expected to be a form (token, password, verif_password fields, plus a CSRF token) that submits as a POST to /reset-password on this ProxyAuth instance. See Password Reset & First-Login Forced Change for the full request/response shape.


letsencrypt (optional)

Settings for automatic Let's Encrypt certificate renewal — see Automatic Certificate Renewal (ACME) for the full mechanism and setup guide. Every field is optional; the whole block can be omitted if you're not using certbot_renew on any vhost. acme is also still accepted as an alias for this key, for configs written before it was renamed.

"letsencrypt": {
  "check_interval_secs": 3600,
  "renew_before_days": 30,
  "directory_url": "https://acme-v02.api.letsencrypt.org/directory",
  "contact_email": "you@example.com",
  "account_credentials_path": "/etc/proxyauth/acme/account.json"
}
Sub-key Type Default Description
check_interval_secs integer 3600 How often, in seconds, every certbot_renew: true vhost is checked for renewal.
renew_before_days integer 30 Renew when the certificate has this many days or fewer left before expiring.
directory_url string Let's Encrypt production The ACME directory URL. Point at https://acme-staging-v02.api.letsencrypt.org/directory while testing.
contact_email string (none) Contact email for the ACME account.
account_credentials_path string /etc/proxyauth/acme/account.json Where the ACME account's credentials are persisted between restarts. Written with 0600 permissions.

Secret handling

secret, token_admin, databases.password (if databases is set), and every user's otpkey are stored in plaintext in config.json (password on a file-based user is the one exception — it's hashed with Argon2 in place after first startup). This is a deliberate, common trade-off for a self-hosted config file, not an oversight, but it does mean:

  • Treat config.json like any other secret: restrict its file permissions (chmod 600), and never commit it to source control.
  • Prefer environment-specific secret injection (e.g. mounting the file from a secrets manager, or templating it at deploy time) over hand-editing it in a shared repo.
  • secret in particular should be long (64+ characters) and unique per environment — reusing it between staging and production means a leak in one compromises both.

Full example

{
  "token_expiry_seconds": 3600,
  "secret": "REPLACE-ME-with-a-long-random-string-at-least-64-chars",
  "token_admin": "REPLACE-ME-admin-token",
  "host": "0.0.0.0",
  "port": 8080,
  "worker": 4,
  "num_instances": 2,
  "tls": true,
  "timezone": "Europe/Paris",

  "login_via_otp": true,
  "fast": false,
  "session_cookie": true,
  "max_age_session_cookie": 3600,
  "csrf_token": true,
  "plugin_anti_replay": true,
  "anti_replay_window_secs": 60,
  "login_redirect_url": "/dashboard",
  "logout_redirect_url": "/login",

  "ratelimit_auth": { "requests_per_second": 5, "burst": 10 },
  "ratelimit_proxy": { "requests_per_second": 50, "burst": 100 },

  "trust_proxy_forward_for": ["10.0.0.1", "10.0.0.0/24"],
  "cors_origins": ["https://app.example.com"],

  "stats": true,
  "log": { "type": "local", "write_max_logs": "2000" },

  "logging": {
    "enabled": true,
    "format": "[time] [vhost] [ip] [username] [method] [path] [status] [length] [request-time]",
    "routes": { "/healthz": false }
  },

  "compression": {
    "enabled": true,
    "algorithm": "br, gzip",
    "level": 5,
    "min_size": 1024
  },

  "databases": {
    "type": "postgres",
    "host": "127.0.0.1",
    "db_name": "proxyauth",
    "user": "proxyauth",
    "password": "REPLACE-ME-db-password",
    "connect_timeout_secs": 5,
    "refresh_interval_secs": 30,
    "incremental_window_secs": 300,
    "full_refresh_interval_secs": 300,
    "deleted_retention_secs": 86400,
    "purge_interval_secs": 3600
  },

  "users": [
    {
      "username": "admin",
      "password": "changeme",
      "roles": ["admin"],
      "allow": ["10.0.0.0/24"]
    },
    {
      "username": "alice",
      "password": "changeme-too",
      "roles": ["user"]
    }
  ]
}

See also

  • Anti-Replay Protection — plugin_anti_replay/anti_replay_window_secs in depth, signature format, and the ProxyAuth browser extension.
  • Group- and Role-Based Access Control — User.groups/roles in depth, and how routes.yml uses them to gate access.
  • TOTP Enrollment & Reset — how login_via_otp and per-user otpkey values are managed at runtime.
  • Logging — the logging and log blocks in depth: placeholders, disable precedence, transport modes.
  • HTTP Compression Support — the compression block in depth, and upstream_identity.
  • Automatic Certificate Renewal (ACME) — the letsencrypt block in depth, and the native Let's Encrypt integration end to end.
  • TLS & Certificates — the tls/host fields in context, certificate loading, hot-reload.
  • CLI Reference — managing database-backed users from the command line, plus routes-audit/check-access/check-routes to sanity-check who can reach what.
  • routes.yml Reference — per-route backend, load-balancing, and access-control configuration; not covered by this page.