0

I hosted a clickhouse server on azure VM (I'm able to run clickhouse-client inside the VM) with a nginx proxy, below is the nginx setting

      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;
           }
   

I'm able to curl both endpoint with proper response, e.g.

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.

However, when i try to do clickhouse-client -h myhost.cloudapp.azure.com --port 6000, I get the following.

 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)

The connection setting for clickhouse-server is as following:

<listen_host>::</listen_host>

I don't know what I'm doing wrong, any hints are appreciated.

dex
  • 77
  • 4
  • 13
  • are you sure that port 6000 is not shared with another app (see https://stackoverflow.com/questions/50490543/unexpected-packet-from-server-localhost9000-1)? – vladimir Jan 26 '21 at 07:03
  • Check that version of *clickhouse-server* and *clickhouse-client* the same. – vladimir Jan 26 '21 at 07:04

1 Answers1

2

9000 -- tcp protocol not HTTP. You need to configure nginx as TCP reverse proxy

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;
  }
}
Denny Crane
  • 11,574
  • 2
  • 19
  • 30