Skip to content

Gymbagfile & JSON Schema Reference ​

By default, Gymbag probes ./gymbag.json, ./Gymbagfile, and ./Caddyfile in the working directory (or --config <path> / GYMBAG_CONFIG). It natively parses gymbag.json, Gymbagfile / Caddyfile v2, nginx.conf, and Apache (httpd.conf / apache2.conf).

Global Options Block { ... } ​

An optional top-level { ... } block configures server-wide TLS, ACME, networking, threat/VPN/AI feeds, remote rules, verification portal settings, and default WAF policies:

caddyfile
{
    email ops@example.com
    ssl_provider letsencrypt
    # eab YOUR_EAB_KID YOUR_EAB_HMAC_KEY
    # account_key certs/acme-account.pem
    # ssl_key certs/domain.key

    bind 0.0.0.0
    http_port 80
    https_port 443
    admin 127.0.0.1:2019
    cert_dir certs
    auto_hosts on
    hsts on

    # Default clearance cookie/IP timeout (seconds or duration: 30m, 12h, 7d)
    verify_timeout 24h

    # Shared HTTPS verification portal for SSH & Minecraft
    # verify_url https://verify.example.com:8443
    # verify_port 8443

    # Optional Redis store for shared PoW nonces, rate limits, and SSH/MC gate tickets
    # redis redis://127.0.0.1:6379/0

    # IP threat intel, VPN/Tor detection & AI crawler IP feeds
    ip_security on
    ip_security_action verify
    ip_reputation on
    vpn_detection on
    ai_ip_list on
    intel_refresh 6h

    # Shared remote firewall rules (Gymbagfile syntax or JSON)
    # remote_rules https://rules.example.com/baseline.rules
    # remote_rules_refresh 5m

    # Global custom rules evaluated before remote & site rules
    block ip 198.51.100.99 192.0.2.0/24
}

Global Directives ​

DirectiveDescriptionDefault
email / acme_emailContact email for ACME registration (and ZeroSSL auto-EAB)—
ssl_provider / caletsencrypt, letsencrypt_staging, zerossl, google, ssl.com, litessl, buypass, local, or URLauto (letsencrypt / local)
acme_directoryExplicit RFC 8555 ACME v2 directory URLLet's Encrypt v2
eab <kid> <hmac>External Account Binding credentials (or eab_kid / eab_hmac_key)—
account_keyExisting ECDSA or RSA ACME account PEM path<cert_dir>/acme-account.pem
ssl_keyExisting private key path for ACME CSRsAuto-generated
tlsauto, acme, local, selfsigned, or <cert.pem> <key.pem>auto
key_passwordPassphrase for encrypted PEM private keys—
cert_dirDirectory for certs, local CA, secret, intel cache, and rule cachecerts
renew_intervalCertificate renewal check interval (seconds or duration like 12h)43200 (12h)
renew_within_daysRenew certificates within N days of expiry30
auto_hostsManage /etc/hosts entries for localhost / *.internal (on/off)on
hstsSend Strict-Transport-Security header (on/off)on for public ACME certs
bind / bind_hostListen IP address127.0.0.1 (local HTTP) / 0.0.0.0 (public HTTP, SSH, or MC)
http_port / https_portHTTP redirect/ACME port & HTTPS gateway port80 / 443
verify_urlPublic HTTPS URL for the SSH/Minecraft verification portalServer IP + IP SSL cert
verify_portShared HTTPS port for the SSH/Minecraft verification portal8443
verify_server { ... }Optional block supporting url, port, and tls <cert> <key>—
adminLocal Admin REST API listen address (e.g. 127.0.0.1:2019 or off)disabled
redis / redis_urlRedis connection URL (redis:// or rediss://)in-memory store
secretHMAC secret for waf_clearance cookies<cert_dir>/secret
trusted_proxiesTrusted downstream proxy IPs/CIDRs for X-Forwarded-For—
ip_securityEnable threat-intel CIDR feeds (on/off)on
ip_security_actionThreat-intel match action (verify or block)verify
ip_reputationEnable live Shodan InternetDB & StopForumSpam lookups (plus live VPN API lookups when vpn_detection is on)on
vpn_detection / vpn_detectFlag free VPN/proxy/Tor IPs as suspicious at verify levels 1 & 3 (on/off)on
ai_ip_listEnable official AI crawler CIDR lists (on/off)on
intel_refreshFeed refresh interval (seconds or duration like 6h)21600 (6h)
threat_feed / ai_ip_feed / vpn_feedAdditional custom IP feed URLs (threat_feeds, ai_ip_feeds, vpn_feeds also work)—
remote_rulesHTTP/HTTPS remote firewall rule URLs inherited by all sites—
remote_rules_refreshRefresh interval for remote rule URLs (seconds or duration; alias rules_refresh)300 (5m)
rules_fileLocal .rules/.json rule file (rules_file <path> [dynamic|static])—
rules_dirLocal rules directory (rules_dir <path> [dynamic|static])—
ruleset <name> { ... }Named local or remote rule source block (source/file/dir/url, dynamic on|off)—
rules_watch_intervalPolling interval for dynamic local rule files and folders2 (2s)
verify_timeout / clearance_ttlDefault clearance lifetime (seconds or duration like 30m, 12h, 7d)86400 (24h)
authelia <url> [{ ... }]Default Authelia forward-auth settings inherited by sites writing bare authelia—
forward_auth <url> { ... }Generic Caddy v2 forward-auth template—

Site Block Directives ​

caddyfile
app.example.com, www.example.com {
    reverse_proxy http://localhost:3000 http://localhost:3001
    verify 3
    difficulty 4
    rate_limit 240 60s
    challenge_ttl 5m
    verify_timeout 12h
    cookie_name waf_clearance
    cookie_secure true
    default_rules on
    remote_rules https://rules.example.com/app.rules

    allow ip 10.0.0.0/8
    block path /internal-only*
}
DirectiveDescription
reverse_proxy <urls...>One or more upstream targets (round-robin load balanced; supports :3000 shorthand)
verify [0|1|2|3|off]Verification level (bare verify enables level 3)
protect <on|off>Enable or disable WAF verification
difficulty <1-5>SHA-256 leading-hex-zero PoW difficulty
rate_limit <count> [window]Per-IP rate limit and optional window (rate_window also accepted)
challenge_ttl <sec|dur>PoW challenge nonce expiry (e.g. 300 or 5m)
clearance_ttl <sec|dur>Verified clearance lifetime (aliases: verify_timeout, verified_timeout, clearance_timeout)
cookie_name <name>Clearance cookie name
cookie_secure <bool>Whether clearance cookie sets Secure
default_rules <on|off>Toggle built-in baseline rules
remote_rules <urls...>Remote firewall rules URLs (Gymbagfile syntax or JSON)
rules_file <path> [dynamic|static]Local .rules or .json file (optionally hot-reloaded)
rules_dir <path> [dynamic|static]Directory of .rules/.json files (optionally hot-reloaded)
ruleset <name> { ... }Named rule source block (source/file/dir/url, dynamic on|off)
handle / handle_path / routeOrdered path-matched route blocks (reverse_proxy, authelia/forward_auth, root + file_server, respond, redir, header)
authelia [url] [{ ... }]Enforce Authelia forward auth on the site (bare authelia inherits global { authelia ... }; supports uri, portal_url, copy_headers, path, except, header, timeout, insecure_skip_tls)
forward_auth [matcher] <url> { ... }Caddy v2 forward-auth directive (supports uri, copy_headers, header_up, transport http { tls_insecure_skip_verify })
root / file_server / try_filesStatic file serving, directory listings (browse), and SPA fallback
respond / redir / headerStatic responses, redirects ({scheme}, {host}, {uri}, {path}, {query}), and header edits
ai_bots <patterns...>Extra User-Agent substrings treated as AI crawlers
suspicious_uas <patterns...>Extra User-Agent substrings treated as suspicious
suspicious_paths <prefixes...>Extra path prefixes treated as suspicious probes
tls <cert> <key>Per-site SNI certificate and private key paths
allow | verify | block ...Shorthand custom firewall rule
rule "name" { ... }Multi-condition custom firewall rule block

ssh and minecraft Service Blocks ​

Top-level ssh [port] { ... } and minecraft [port] { ... } (alias mc) blocks configure TCP PoW gating:

caddyfile
ssh {
    port 22
    upstream 127.0.0.1:41822
    verify 3
    difficulty 4
    rate_limit 60 60s
    clearance_ttl 24h
    allow ip 10.0.0.0/8
}

minecraft {
    port 25565
    upstream 127.0.0.1:48291
    server_jar /srv/mc/paper.jar
    jvm_args -Xms1G -Xmx4G
    server_properties /srv/mc/server.properties
    verify 3
    rate_limit 60 60s
}
DirectiveDescriptionDefault
enabled <bool>Enable or disable the block without removing ittrue
port <port>Public listen port (can also be written as ssh 2222 { ... })22 (SSH) / 25565 (Minecraft)
upstream <host:port>Backend TCP target (reverse_proxy / proxy also accepted, e.g. :2222, tcp://127.0.0.1:25566)— (127.0.0.1:25566 when server_jar is set)
server_properties <path>Path to server.properties (minecraft block only)—
server_jar <path> / jarPath to Minecraft .jar to auto-start alongside Gymbag (minecraft block only)—
java_path <bin> / javaExplicit Java binary override (minecraft block only)Auto-selected
jvm_args <flags...>JVM arguments passed before -jar (minecraft block only)—
server_args <args...>Extra arguments passed after the JAR path (minecraft block only)—
work_dir <dir>Working directory for the managed Minecraft process (minecraft block only)JAR directory
auto_restart <on|off>Automatically restart the Minecraft server if it exits unexpectedly (minecraft block only)on
console <on|off>Bring the managed Minecraft server console into Gymbag foreground, gymbag console, and /api/v1/minecraft/console (mc_console alias; minecraft block only)off
verify [0|1|2|3|off]Verification level (bare verify sets 3)3
protect <on|off>Toggle PoW verification for this serviceon
difficulty <1-5>PoW leading-hex-zero difficulty4
rate_limit <count> [window]Per-IP connection rate limit and window60 / 60s
challenge_ttl <sec|dur>Challenge token expiry300 (5m)
clearance_ttl <sec|dur>Cleared IP lifetime (verify_timeout also accepted)86400 (24h)
verify_url / verify_portPer-service override for the verification link printed in disconnect messagesGlobal verify_url / verify_port
allow | verify | block ... / ruleCustom rules matching IP/CIDR or client banner/username (user_agent)—

Duration Syntax ​

Time directives (clearance_ttl / verify_timeout, challenge_ttl, rate_window, intel_refresh, remote_rules_refresh, rules_watch_interval, and renew_interval) accept:

  • Plain integer seconds: 300, 3600, 86400
  • Go durations: 45s, 30m, 12h, 1h30m
  • Day & week shorthand: 1d, 7d, 1d12h, 2w

Formatting & Validation ​

bash
./gymbag validate --config Gymbagfile
./gymbag fmt --overwrite Gymbagfile

JSON Configuration (gymbag.json) ​

gymbag init generates concise gymbag.json by default, omitting unused services and default values (--format gymbagfile switches to Caddy syntax):

bash
./gymbag init -d app.example.com -u :3000 --verify-timeout 12h --rules-dir ./rules.d --rules-dynamic

Top-level JSON keys (DisallowUnknownFields is enforced):

  • sites: array of {domain, upstreams, routes, headers, auth, protect, waf, cert_file, key_file}, where waf holds {verify_level, difficulty, challenge_ttl, clearance_ttl, cookie_name, cookie_secure, rate_limit, rate_window, default_rules, rules, remote_rules, rule_sources, custom_ai_bots, custom_suspicious_uas, custom_suspicious_paths} and auth holds {provider, url, uri, portal_url, copy_headers, headers, paths, except_paths, timeout, insecure_skip_tls}.
  • authelia: optional global forward-auth object matching site auth.
  • ssh: {enabled, port, upstream, protect, verify_level, difficulty, challenge_ttl, clearance_ttl, rate_limit, rate_window, verify_url, verify_port, rules}.
  • minecraft: {enabled, port, upstream, server_properties, server_jar, java_path, jvm_args, server_args, work_dir, auto_restart, console, protect, verify_level, difficulty, challenge_ttl, clearance_ttl, rate_limit, rate_window, verify_url, verify_port, rules}.
  • verify: {url, port, cert_file, key_file}.
  • bind_host, http_port, https_port, admin_addr, remote_rules_refresh, rules_watch_interval, redis_url, secret, trusted_proxies.
  • tls: {mode, provider, cert_file, key_file, key_password, account_key_file, eab_kid, eab_hmac_key, auto_hosts, cert_dir, acme_email, acme_directory, renew_interval, renew_within_days, hsts}.
  • intel: {ip_security, ip_security_action, live_reputation, ai_ip_list, vpn_detection, refresh_interval, threat_feeds, ai_ip_feeds, vpn_feeds}.
  • defaults: shared base waf object.

You can also convert nginx.conf, Apache httpd.conf/apache2.conf, or Caddyfile to gymbag.json:

bash
./gymbag config convert -c /etc/nginx/nginx.conf -o gymbag.json --format json

Pure Go stdlib · Zero external Go dependencies