Chproxy
Chproxy is an open-source HTTP proxy and load balancer purpose-built for ClickHouse®. A community-driven project, it provides robust traffic management and security features for ClickHouse® clusters.
Chproxy is a reliable and high-performance solution which ensures secure and efficient access to production-grade ClickHouse® clusters.
Routing and load balancing
- Proxying queries to different ClickHouse® clusters based on the incoming user.
- Balancing query load across replicas and nodes using the
least loaded + round robinstrategy. - Node health monitoring to prevent routing queries to unhealthly nodes.
User management and security
- Mapping incoming users to cluster users to prevent the exposure of real usernames and passwords.
- Mapping multiple incoming users to a single ClickHouse® user.
- Restricted HTTP and HTTPS access based on IP address or IP mask lists.
- Restricted access for individual users based on IP address or IP mask lists.
Resource and performance control
- Limits on query duration per user with forced termination via
KILL QUERY. - Limits on query rates per user.
- Limits on the number of concurrent queries per user.
- Enforcing query execution delays until user limits are satisfied.
- Independent configuration of all limits for each incoming user and cluster user.
Caching and optimization
- Granular configuration of response caching for each individual user.
- Native
thundering herdmitigation for response caches.
Connection security
- Support for incoming queries over HTTP and HTTPS.
- Automatic issuance and renewal of HTTPS certificates via Let’s Encrypt®.
- Proxying queries to each configured cluster over HTTP or HTTPS.
Monitoring and management
- Exporting performance metrics in Prometheus format.
- Adding user and IP data to the
User-Agentheader for querying fromsystem.query_log.http_user_agent. - Configuration updates without a restart via the
SIGHUPsignal. - Streamlined launch and management by providing the configuration file path to a single chproxy binary.
-
Create a cloud network and a subnet to host the virtual machine (VM).
-
Create a security group for the VM named
vm-proxyin your new cloud network and configure the rules as follows:Traffic direction Description Port range Protocol Source / Destination CIDR blocks IngressClickHouse8123TCPCIDR0.0.0.0/0IngressHTTP8080TCPCIDR0.0.0.0/0IngressSSH22TCPCIDR0.0.0.0/0EgressAny Egress0-65535AnyCIDR0.0.0.0/0 -
Create a security group for the VM named
vm-testin the same network and configure the rules as follows:Traffic direction Description Port range Protocol Source / Destination CIDR blocks IngressClickHouse8123TCPCIDR0.0.0.0/0IngressHTTP80TCPCIDR0.0.0.0/0IngressSSH22TCPCIDR0.0.0.0/0EgressAny Egress0-65535AnyCIDR0.0.0.0/0 -
Get an SSH key pair for connection to the VM.
-
Create and configure a VM to test the application:
-
When creating the VM, specify the following:
- Under Boot disk image on the Marketplace tab, select an Ubuntu or Debian image, e.g.,
Ubuntu 24.04. - Under Network settings, specify the earlier created cloud network, subnet, and security group for
vm-test. - Under Access, specify the username and public SSH key for connection to the VM.
- Under General information, specify the VM name:
vm-test.
- Under Boot disk image on the Marketplace tab, select an Ubuntu or Debian image, e.g.,
-
Learn the public IP address of
vm-test. -
Connect to
vm-testover SSH. Use the username you set when creating the VM and the private SSH key you created earlier. -
Install ClickHouse Server, ClickHouse Client, and ClickHouse Keeper as detailed in Install ClickHouse on Debian/Ubuntu.
-
Add the following to
/etc/clickhouse-server/config.xmlright after the<clickhouse>line:<listen_host>0.0.0.0</listen_host>The
0.0.0.0address is not recommended in production environments. -
Add a rule allowing incoming connections to port
8123:sudo iptables -I INPUT -p tcp --dport 8123 -j ACCEPT sudo apt-get update && sudo apt-get install -y netfilter-persistent sudo netfilter-persistent save -
Restart ClickHouse Server:
sudo systemctl restart clickhouse-server
-
-
Install and configure the application:
-
In the Marketplace, find Chproxy and click Create VM:
-
Under Network settings, specify the earlier created cloud network, subnet, and security group for
vm-proxy. -
Under Access, specify the username and public SSH key for connection to the VM.
-
Under General information, specify the VM name:
vm-proxy. -
Complete setting up your VM and click Create VM.
Wait for the VM to be created and the application to be installed: this may take up to 10 minutes.
-
-
Learn the public IP address of
vm-proxy. -
Connect to
vm-proxyover SSH. Use the username you set when creating the VM and the private SSH key you created earlier. -
Replace the
/etc/chproxy/chproxy.ymlfile contents with the following:hack_me_please: true server: http: listen_addr: ":8123" users: - name: "default" to_cluster: "default" to_user: "default" # by default each cluster has `default` user which can be overridden by section `users` clusters: - name: "default" nodes: ["<VM_public_IP_address>:8123"]In the
nodesfield, specifyvm-test's public IP address.We recommend using
hack_me_please: falsein the production environment. -
Add a rule allowing incoming connections to port
8123:sudo iptables -I INPUT -p tcp --dport 8123 -j ACCEPT sudo apt-get update && sudo apt-get install -y netfilter-persistent sudo netfilter-persistent save -
Restart Chproxy and check its status:
sudo systemctl restart chproxy sudo systemctl status chproxyResult:
● chproxy.service - Chproxy Loaded: loaded (/etc/systemd/system/chproxy.service; enabled; preset: enabled) Active: active (running) since Thu 2026-03-05 23:10:11 UTC; 7s ago Docs: https://www.chproxy.org/ ... Mar 05 23:10:11 vm-proxy chproxy[1046]: INFO: 2026/03/05 23:10:11 main.go:190: Serving http on ":8123"
-
-
Test your connection:
-
Connect to
vm-testover SSH. -
Run the command below specifying the
vm-proxypublic IP address:curl "http://<VM_public_IP_address>:8123/?query=SELECT%201"Result:
1If the command is successful, your ClickHouse® on
vm-testis connected to Chproxy onvm-proxy.
-
- Load balancing across multiple ClickHouse® clusters.
- Restricted user access to specific clusters based on IP addresses.
- Response caching to improve query performance.
- Health monitoring of ClickHouse® nodes and automatic traffic failover.
- Controlling query rates and execution times for individual users.
- Automatic issuance and renewal of HTTPS certificates via Let’s Encrypt®.
- Masking actual ClickHouse® credentials from client applications.
Yandex Cloud technical support is available 24/7. The types of requests you can submit and the relevant response times depend on your pricing plan. You can switch to the paid support plan in the management console. You can learn more about the technical support terms and conditions here.