# Securing ClickHouse and MySQL Flow Storage | ntop

[Blog](https://www.ntop.org/blog/)[ntop](https://www.ntop.org/category/ntop/)[ntopng](https://www.ntop.org/category/ntopng/)

# Securing ClickHouse and MySQL Flow Storage

December 11, 202320 min read

ntopng stores flows data in various databases including MySQL, Elastic and ClickHouse that is the database storage that we have selected as it outpaces the others in terms of speed and reduced disk space. ClickHouse is a columnar database and while it is very fast during data access, it is optimised for batch data insertion. This means that ntopng imports flow data as follows:

-   High cardinality data such as flows are saved in a temporary file and imported every minute using *clickhouse-client*. The default TCP communication port is 9000.
-   Low-cardinality data such as alerts are stored with SQL queries. In this case we perform queries using the MySQL driver part or ClickHouse as it does not have a native SQL query engine. The default TCP communication port used by the MySQL driver is 9004.

![](/images/2023/12/ntopng-Clickhouse.webp)

Out of the box ClickHouse uses plain text communications but you can enable TLS in a few steps as described in [this document](https://clickhouse.com/docs/en/guides/sre/ssl-user-auth) and also secure the MySQL configuration. All settings are specified in */etc/clickhouse-server/config.xml* as follows:

-   <tcp\_port> is used for insecure clickhouse-client connection.
-   <tcp\_port\_secure> is used for secure (TLS) clickhouse-client connection.
-   <mysql\_port> defines the port where the MySQL driver is listening to. ClickHouse does not offer TLS support for the MySQL driver, hence if you want to secure communications you need to put a [TLS proxy](https://en.wikipedia.org/wiki/TLS_termination_proxy) in front of that port.

    <!-- Port for interaction by native protocol with:                                                                                                                                                                                                                            
         - clickhouse-client and other native ClickHouse tools (clickhouse-benchmark, clickhouse-copier);                                                                                                                                                                         
         - clickhouse-server with other clickhouse-servers for distributed query processing;                                                                                                                                                                                      
         - ClickHouse drivers and applications supporting native protocol                                                                                                                                                                                                         
         (this protocol is also informally called as "the TCP protocol");                                                                                                                                                                                                         
         See also 'tcp\_port\_secure' for secure connections.                                                                                                                                                                                                                       
    -->
    <tcp\_port>9000</tcp\_port>

    <!-- Compatibility with MySQL protocol.                                                                                                                                                                                                                                       
         ClickHouse will pretend to be MySQL for applications connecting to this port.                                                                                                                                                                                            
    -->
    <mysql\_port>9004</mysql\_port>

    <!-- Native interface with TLS.                                                                                                                                                                                                                                               
         You have to configure certificate to enable this interface.                                                                                                                                                                                                              
         See the openSSL section below.                                                                                                                                                                                                                                           
    -->
    <tcp\_port\_secure>9440</tcp\_port\_secure>

    <openSSL>
      <server> <!-- Used for https server AND secure tcp port -->
             <!-- openssl req -subj "/CN=localhost" -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout /etc/clickhouse-server/server.key -out /etc/clickhouse-server/server.crt -->
            <certificateFile>/etc/clickhouse-server/server.crt</certificateFile>
            <privateKeyFile>/etc/clickhouse-server/server.key</privateKeyFile>
            <!-- dhparams are optional. You can delete the <dhParamsFile> element.                                                                                                                                                                                                
                 To generate dhparams, use the following command:                                                                                                                                                                                                                 
                  openssl dhparam -out /etc/clickhouse-server/dhparam.pem 4096                                                                                                                                                                                                    
                 Only file format with BEGIN DH PARAMETERS is supported.                                                                                                                                                                                                          
              -->
            <!-- <dhParamsFile>/etc/clickhouse-server/dhparam.pem</dhParamsFile>-->
            <verificationMode>none</verificationMode>
            <loadDefaultCAFile>true</loadDefaultCAFile>
            <cacheSessions>true</cacheSessions>
            <disableProtocols>sslv2,sslv3</disableProtocols>
            <preferServerCiphers>true</preferServerCiphers>

            <invalidCertificateHandler>
                <!-- The server, in contrast to the client, cannot ask about the certificate interactively.                                                                                                                                                                       
                     The only reasonable option is to reject.                                                                                                                                                                                                                     
                -->
                <name>RejectCertificateHandler</name>
            </invalidCertificateHandler>
        </server>
..
    </openSSL>

The -F flag has been enhanced to specify the use of secure ports by adding a ‘s’ after the port. Example:

-   \-F “clickhouse;127.0.0.1@9000,9004;ntopng;default;” \[Insecure\]
    
-   \-F “clickhouse;127.0.0.1@9440**s**,9004;ntopng;default;” \[ClickHouse TLS, plain MySQL\]
    
-   \-F “clickhouse;127.0.0.1@9440**s**,9014**s**;ntopng;default;” \[ClickHouse TLS, MySQL TLS (behing a TLS proxy active on port 9014\]

Note that the ‘s’ option is also available when using MySQL (without ClickHouse) with ntopng (i.e. -F “mysql;127.0.0.1;ntopng;root;“)

It’s now time to connect to your ClickHouse (or MySQL) database over TLS for secure database communications.

Enjoy !

## Keep reading

nDPINov 7, 2026

### [Detecting CVE-2026-98432 using nDPI/ntopng](https://www.ntop.org/detecting-cve-2026-98432-using-ndpi-ntopng/)

CVE-2026-98432 is a critical, 9.8-severity use-after-free (UAF) vulnerability in the Linux kernel’s IPv4 TCP networking stack. It allows an unauthenticated remote attacker to potentially cause system crashes, memory corruption, or execute arbitrary commands with root privileges. From a network stand

[![](/images/2026/09/Screenshot-2026-09-09-151028-1.webp)](https://www.ntop.org/october-20th-join-us-for-the-ntopng-7-0-webinar/)

AnnounceOct 5, 2026

### [October 20th: Join us for the ntopng 7.0 Webinar](https://www.ntop.org/october-20th-join-us-for-the-ntopng-7-0-webinar/)

Is your network monitoring keeping pace with AI, larger infrastructures, and the growing need for real observability? We’re excited to introduce ntopng 7.0, alongside new releases of the rest of the ntop…

[![](/images/2026/09/Screenshot-2026-09-09-163410-1.webp)](https://www.ntop.org/ntopng-user-interface-introducing-the-new-navigation-bar/)

ntopngSep 21, 2026

### [ntopng User Interface: Introducing the New Navigation Bar](https://www.ntop.org/ntopng-user-interface-introducing-the-new-navigation-bar/)

In our continuous effort to improve user experience and make network monitoring more intuitive, we have completely redesigned the ntopng Navigation Bar. As our feature set expands—with crucial additions like the nAnalyst…

## Try it on your own network

Download the free Community edition and see your first flows in five minutes.

[Download ntopng free](https://www.ntop.org/support/documentation/software-installation/)[Talk to an engineer](https://www.ntop.org/support/need-help/contacts/)
Source: https://www.ntop.org/securing-clickhouse-flow-storage/