无法使用 clickhouse-client 连接到远程 clickhouse-server

fail to connect to remote clickhouse-server with clickhouse-client

我在 azure VM 上托管了一个 clickhouse 服务器 (我可以 运行 clickhouse-client inside the VM) 使用 nginx 代理,下面是 nginx设置

      server {
           listen  5000;
           server_name     myhost.cloudapp.azure.com;
           location / {
                   proxy_pass http://localhost:8123;
           }


   server {
           listen  6000;
           server_name     myhost.cloudapp.azure.com;
           location / {
                   proxy_pass http://localhost:9000;
           }
   

我能够通过适当的响应来卷曲两个端点,例如

curl http://myhost.cloudapp.azure.com:6000                
Port 9000 is for clickhouse-client program.
You must use port 8123 for HTTP.

curl http://myhost.cloudapp.azure.com:5000                
Ok.

但是,当我尝试执行 clickhouse-client -h myhost.cloudapp.azure.com --port 6000 时,我得到以下信息。

 clickhouse-client -h myhost.cloudapp.azure.com --port 6000
 ClickHouse client version 21.1.2.15 (official build).
 Connecting to myhost.cloudapp.azure.com:6000 as user default.
 Code: 102. DB::NetException: Unexpected packet from server bs- 
 clickhouse.westeurope.cloudapp.azure.com:6000 (expected Hello or Exception, got Unknown packet)

clickhouse-server的连接设置如下:

<listen_host>::</listen_host>

我不知道我做错了什么,欢迎任何提示。

9000 -- tcp 协议不是 HTTP。需要配置nginx为TCP反向代理

NGINX transparent TCP proxy

stream {
  upstream syslog {
    server sapvmlogstash01.sa.projectplace.com:514;
    server sapvmlogstash02.sa.projectplace.com:514;
  }
  server {
    listen 514;
    proxy_pass syslog;
  }
}