Configuration Guide
Pingap uses TOML for parameter configuration. For time-related configurations, use formats like 1s
, 1m
, 1h
. For storage size configurations, use formats like 1kb
, 1mb
, 1gb
. Detailed parameter descriptions are as follows:
Basic Configuration
name
: Instance name, defaults toPingap
. If deploying multiple instances on the same machine, configure different nameserror_template
: Optional parameter for HTML template used when errors occur. You can customize the error HTML template. When an error occurs,{{version}}
will be replaced with the Pingap version, and{{content}}
with specific error informationpid_file
: Optional parameter, defaults to/run/pingap.pid
. Configures the process ID record file path. For multiple instances on one machine, configure different pathsupgrade_sock
: Optional parameter, defaults to/tmp/pingap_upgrade.sock
. Configures the socket path for zero-downtime updates, used when switching between old and new Pingap processes. For multiple instances, configure different pathsuser
: Optional parameter, defaults to empty. Sets the daemon process execution usergroup
: Optional parameter, defaults to empty, similar touser
threads
: Optional parameter, defaults to 1. Sets thread count for each service (like server TCP connections). If set to 0, uses CPU core count or cgroup core limitwork_stealing
: Optional parameter, defaults totrue
. Enables work stealing between different threads within the same servicegrace_period
: Sets graceful exit waiting period, defaults to 5 minutesgraceful_shutdown_timeout
: Sets graceful shutdown timeout, defaults to 5 secondsupstream_keepalive_pool_size
: Sets upstream connection pool size, defaults to128
webhook
: Webhook request pathwebhook_type
: Webhook type, supports regular HTTP,webcom
, anddingtalk
webhook_notifications
: Webhook notification types, includingbackend_status
,lets_encrypt
,diff_config
,restart
,restart_fail
, andtls_validity
log_level
: Application log output level, defaults toINFO
log_buffered_size
: Log buffer size, defaults to 0. If set below 4096, no buffer is usedlog_format_json
: Sets JSON formatted loggingsentry
: Sentry DSN configuration, requiresfull feature
versionpyroscope
: Pyroscope connection address(http://ip:port?app=pingap&tag:a=A&tag:b=B
), requires perf version as default version doesn't include pyroscope supportauto_restart_check_interval
: Configuration update check interval, defaults to 90 seconds. If set below 1 second, checks are disabledcache_directory
: Sets cache directory. When set, uses file-based caching. File cache periodically removes long-unused files. Format:/opt/pingap/cache?reading_max=1000&writing_max=500&cache_max=200&cache_file_max_weight=256
reading_max
: Maximum concurrent cache reads (file cache only)writing_max
: Maximum concurrent cache writes (file cache only)cache_max
: Hot data cache limit in file cache, uses tinyufo for memory cache, defaults to 100. Set to 0 to disable memory hot cachecache_file_max_weight
: Maximum cache file weight for tinyufo, defaults to 256, which means 256 * 4096 bytes, files larger than this value will not be cached to tinyufo
cache_max_size
: Maximum cache space limit, shared by all services. Not applicable to file cachetcp_fast_open
: Enables TCP Fast Open to reduce TCP connection establishment latency. Requires specifying backlog size
Upstream
Upstream configuration defines backend service node lists. For domain configurations, the system adds all node addresses based on DNS resolution results (automatic DNS updates require configured service discovery). HTTP health checks are recommended for node status monitoring.
Main parameters:
addrs
: Node address list, format:ip:port [weight]
, weight is optional (defaults to 1)discovery
: Service discovery method. DNS recommended for domains, docker label for docker servicesupdate_frequency
: Service discovery update interval, recommended for dynamic node updatesalgo
: Node selection algorithm, supportshash
andround_robin
. Example:hash:ip
selects nodes by IP hash. Defaults toround_robin
sni
: Required SNI for HTTPS configurationsverify_cert
: Certificate validation requirement for HTTPShealth_check
: Node health check configuration, supports HTTP, TCP, and gRPCipv4_only
: For domain configurations, restricts to IPv4 nodes onlyenable_tracer
: Enables tracer functionality for upstream connection trackingalpn
: ALPN configuration for TLS handshake, defaults to H1connection_timeout
: TCP connection timeout, default nonetotal_connection_timeout
: Connection timeout including TLS handshake for HTTPS, default noneread_timeout
: Read timeout, default noneidle_timeout
: Idle timeout for connection recycling. Set to 0 for no connection reuse. Default nonewrite_timeout
: Write timeout, default nonetcp_idle
: TCP keepalive idle timeouttcp_interval
: TCP keepalive check intervaltcp_probe_count
: TCP keepalive probe counttcp_recv_buf
: TCP receive buffer size
Note: All three parameters (tcp_idle
, tcp_interval
, tcp_probe_count
) must be set for TCP keepalive.
Health Check Configuration
Supports three health check methods:
HTTP(S)
:http://upstream-name/check-path?parameters
TCP
:tcp://upstream-name?parameters
gRPC
:grpc://upstream-name?service=service-name¶meters
Common parameters:
connection_timeout
: Connection timeout, default 3 secondsread_timeout
: Read timeout, default 3 secondscheck_frequency
: Check interval, default 10 secondssuccess
: Consecutive successes needed for healthy status, default 1failure
: Consecutive failures needed for unhealthy status, default 2reuse
: Connection reuse option, default false
Hash Algorithm Options
When using hash for upstream backend selection:
hash:url
: URL-based forwarding for URL-cached serviceshash:ip
: IP-based forwarding for IP-persistent data serviceshash:header:X-User
: Forward based onX-User
header valuehash:cookie:uid
: Forward based onuid
cookie valuehash:query:appKey
: Forward based onappkey
query parameterhash:path
: Path-based forwarding (default hash method)
Location
Location configures request matching rules, header insertion, and plugin associations. Key parameters:
upstream
: Associated upstream configuration. Optional if all processing is handled by pluginspath
: Matching path, detailed usage belowhost
: Matching domain(s), comma-separated for multiple. Use~
prefix for regexproxy_set_headers
: Request headers to set/override when forwarding to upstreamproxy_add_headers
: Request headers to add when forwarding to upstreamrewrite
: Path rewrite rulesweight
: Custom weight for location priorityplugins
: Ordered plugin list for this locationclient_max_body_size
: Maximum client request body sizemax_processing
: Maximum concurrent request limit (0 for unlimited)grpc_web
: Enable grpc-web supportenable_reverse_proxy_headers
: Whether to enable reverse proxy request headers. When enabled, the following headers will be added:X-Real-IP
: Indicates the client's IP addressX-Forwarded-For
: Indicates proxy addresses, added according to x-forwarded-for formatX-Forwarded-Proto
: Indicates the request scheme, such as http or httpsX-Forwarded-Host
: Indicates the request hostX-Forwarded-Port
: Indicates the server port
Path Matching Rules
Location paths support these rules (highest to lowest priority):
- Exact match: Prefix with
=
, e.g.,=/api
matches exact/api
path - Regex match: Prefix with
~
, e.g.,~^/(api|rest)
matches paths starting with/api
or/rest
- Prefix match: e.g.,
/api
matches paths starting with/api
Path Rewrite Rules
Supports regex-based path rewriting (similar to nginx). One rule per configuration. Examples:
^/api/ /
: Replaces/api/
prefix with/
^/(\S*?)/ /api/$1/
: Adds/api
prefix^/(\S*?)/api/(\S*?) /$1/$2
: Removes/api
from path
Supported Header Variables
$hostname
: Host machine hostname$host
: Request host$scheme
: Request scheme (http/https)$remote_addr
: Client address$remote_port
: Client port$server_addr
: Server address$server_port
: Server port$proxy_add_x_forwarded_for
: Proxy addresses in x-forwarded-for format$upstream_addr
: Upstream address
Server
server.x
: Server configuration wherex
is unique server nameaddr
: Listening address(es) inip:port
format, comma-separated for multipleaccess_log
: Optional, disabled by default. Supports formats:combined
,common
,short
,tiny
locations
: Location list for this serverthreads
: Default thread count, 0 for CPU core count, default 1tls_cipher_list
: Pre-TLS 1.3 cipher suitestls_ciphersuites
: TLS 1.3 cipher suitestls_min_version
: Minimum TLS version, default 1.2tls_max_version
: Maximum TLS version, default 1.3global_certificates
: Enable global certificates for unmatched server namesenabled_h2
: Enable HTTP/2 (recommended, uses h2c for HTTP)tcp_idle
: TCP keepalive idle timeouttcp_interval
: TCP keepalive check intervaltcp_probe_count
: TCP keepalive probe counttcp_fastopen
: Enable TCP fast open with backlog sizeprometheus_metrics
: Enable Prometheus metrics (full features version only)otlp_exporter
: OpenTelemetry collector address (full features version only)modules
: Enable specific modules (required for web-grpc)