# Whether to print debug logs.
# By default debug logs are disabled.
# Whether to ignore security checks during config parsing.
# By default security checks are enabled.
# Optional response cache configs.
# Multiple distinct caches with different settings may be configured.
# Cache name, which may be passed into `cache` option on the `user` level.
# Multiple users may share the same cache.
# Cache mode, either [[file_system]] or [[redis]]
# Applicable for cache mode: file_system
# Path to directory where cached responses will be stored.
dir: "/path/to/longterm/cachedir"
# `Kb`, `Mb`, `Gb` and `Tb` suffixes may be used.
# Expiration time for cached responses.
# DEPRECATED: default value equal to `max_execution_time` should be used.
# New configuration parameter will be provided to disable the protection at will.
# When multiple requests with identical query simultaneously hit `chproxy`
# and there is no cached response for the query, then only a single
# request will be proxied to clickhouse. Other requests will wait
# for the cached response during this grace duration.
# This is known as protection from `thundering herd` problem.
# By default `grace_time` is 5s. Negative value disables the protection
# from `thundering herd` problem.
# Applicable for cache mode: redis
# You should use multiple addresses only if they all belong to the same redis cluster.
# Paths to TLS cert and key files for the redis server.
# If you change the cert & key files while chproxy is running, you have to restart chproxy so that it loads them.
# Triggering a SIGHUP signal won't work as for the rest of the configuration.
cert_file: "redis tls cert file path"
key_file: "redis tls key file apth"
# Allow to skip the verification of the redis server certificate.
insecure_skip_verify: true
# Optional network lists, might be used as values for `allowed_networks`.
# Each item may contain either IP or IP subnet mask.
networks: ["127.0.0.0/24", "10.10.0.1"]
networks: ["10.10.10.0/24"]
# Maximum total size of fail reason of queries. Config prevents large tmp files from being read into memory, affects only cachable queries
# If error reason exceeds limit "unknown error reason" will be stored as a fail reason
max_error_reason_size: 100GB
# Optional lists of query params to send with each proxied request to ClickHouse.
# These lists may be used for overriding ClickHouse settings on a per-user basis.
# Group name, which may be passed into `params` option on the `user` level.
# List of key-value params to send
- key: "max_memory_usage"
- key: "max_bytes_before_external_group_by"
- key: "max_memory_usage"
- key: "max_columns_to_read"
- key: "max_execution_time"
# Settings for `chproxy` input interfaces.
# Configs for input http interface.
# The interface works only if this section is present.
# TCP address to listen to for http.
# May be in the form IP:port . IP part is optional.
# List of allowed networks or network_groups.
# Each item may contain IP address, IP subnet mask or a name
# By default requests are accepted from all the IPs.
allowed_networks: ["office", "reporting-apps", "1.2.3.4"]
# ReadTimeout is the maximum duration for proxy to reading the entire
# request, including the body.
# WriteTimeout is the maximum duration for proxy before timing out writes of the response.
# Default is largest MaxExecutionTime + MaxQueueTime value from Users or Clusters
# IdleTimeout is the maximum amount of time for proxy to wait for the next request.
# Configs for input https interface.
# The interface works only if this section is present.
# TCP address to listen to for https.
# Paths to TLS cert and key files.
# If you change the cert & key files while chproxy is running, you have to restart chproxy so that it loads them.
# Triggering a SIGHUP signal won't work as for the rest of the configuration.
# Certificates are automatically issued and renewed if this section
# There is no need in cert_file and key_file if this section is present.
# Autocert requires application to listen on :80 port for certificate generation
# Path to the directory where autocert certs are cached.
# The list of host names proxy is allowed to respond to.
# See https://godoc.org/golang.org/x/crypto/acme/autocert#HostPolicy
allowed_hosts: ["example.com"]
# Metrics in prometheus format are exposed on the `/metrics` path.
# Access to `/metrics` endpoint may be restricted in this section.
# By default access to `/metrics` is unrestricted.
allowed_networks: ["office"]
# Proxy settings enable parsing proxy headers in cases where
# CHProxy is run behind another proxy.
# Configs for input users.
# Name and password are used to authorize access via BasicAuth or
# via `user`/`password` query params.
# Password is optional. By default empty password is used.
# Requests from the user are routed to this cluster.
to_cluster: "first cluster"
# Input user is substituted by the given output user from `to_cluster`
# before proxying the request.
# Whether to deny input requests over HTTP.
# Whether to allow `CORS` requests like `tabix` does.
# By default `CORS` requests are denied for security reasons.
# Requests per minute limit for the given input user.
# By default there is no per-minute limit.
# Response cache config name to use.
# By default responses aren't cached.
# An optional group of params to send to ClickHouse with each proxied request.
# These params may be set in param_groups block.
# By default no additional params are sent to ClickHouse.
# The maximum number of requests that may wait for their chance
# to be executed because they cannot run now due to the current limits.
# This option may be useful for handling request bursts from `tabix`
# or `clickhouse-grafana`.
# By default all the requests are immediately executed without
# The maximum duration the queued requests may wait for their chance
# This option makes sense only if max_queue_size is set.
# By default requests wait for up to 10 seconds in the queue.
to_cluster: "second cluster"
allowed_networks: ["office", "1.2.3.0/24"]
# The maximum number of concurrently running queries for the user.
# By default there is no limit on the number of concurrently
max_concurrent_queries: 4
# The maximum query duration for the user.
# Timed out queries are forcibly killed via `KILL QUERY`.
# By default set to 120s.
# Whether to deny input requests over HTTPS.
# Configs for ClickHouse clusters.
# The cluster name is used in `to_cluster`.
# Protocol to use for communicating with cluster nodes.
# Currently supported values are `http` or `https`.
# By default `http` is used.
# Cluster node addresses.
# Requests are evenly distributed among them.
nodes: ["127.0.0.1:8123", "shard2:8123"]
# User configuration for heart beat requests.
# Credentials of the first user in clusters.users will be used for heart beat requests to clickhouse.
# An interval for checking all cluster nodes for availability
# By default each node is checked for every 5 seconds.
# A timeout of wait response from cluster nodes
# The parameter to set the URI to request in a health check
# By default "/?query=SELECT%201"
request: "/?query=SELECT%201%2B1"
# Reference response from clickhouse on health check request
# Timed out queries are killed using this user.
# By default `default` user is used.
# Configuration for cluster users.
# The user name is used in `to_user`.
max_concurrent_queries: 4
# The cluster may contain multiple replicas instead of flat nodes.
# Chproxy selects the least loaded node among the least loaded replicas.
nodes: ["127.0.1.1:8443", "127.0.1.2:8443"]
nodes: ["127.0.2.1:8443", "127.0.2.2:8443"]
max_concurrent_queries: 4
max_concurrent_queries: 4
allowed_networks: ["office"]