Ad Widget

Collapse

Zabbix TLS connection for front-end web UI - the right way?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jjn
    Junior Member
    • May 2022
    • 5

    #1

    Zabbix TLS connection for front-end web UI - the right way?

    Hello everyone,

    Long time user, first time poster; and I could use some help.

    I've been running Zabbix quite effectively in containers for a while; one for the mysql DB, one for the server and one for the web front end. For reasons that we don't need to get in to, these containers are all on-prem.

    I'm now interested in moving the DB container to a cloud provider. I don't think it matters which one, except that it requires a TLS connection. Getting the Zabbix Server container (zabbix/zabbix-server-mysql:ubuntu-6.0.3​​​​) to connect to the DB using TLS was pretty straightforward, once I realized that you need to set the $ZBX_DBTLSCONNECT env var to 'required' (assuming you've also successfully set $ZBX_DBTLSKEYFILE, $ZBX_DBTLSCAFILE and $ZBX_DBTLSCERTFILE).

    The web UI (zabbix/zabbix-web-nginx-mysql:ubuntu-6.0.3) however, was an entirely different story. At first, the container logs would complain about not being able to connect to the DB, but then I realized that the env var was slightly different and needed to be $ZBX_DB_ENCRYPTION = 'true'. That got the db check in the container entrypoint script to work and nginx running, but the Zabbix web UI would only return a 2002 error. This is more of the less the same issue that is unresolved over here: https://www.zabbix.com/forum/zabbix-...tls-encryption

    I tried setting $ZBX_DB_VERIFY_HOST = false with no luck. I tried updating to Zabbix 6.0.3 with no luck either. Both of them still had the 2002 errors. I confirmed using the mysql binary that the container could connect successfully (mysql --user=zabbix --password --host=<db host> --ssl-ca=server-ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem --ssl-mode=verify_ca) and wrote a simple PHP script to confirm that PHP could connect as well.

    Eventually, the workaround was to modify the public function connect function in MysqlDbBackend.php. Changing "$tls_mode = MYSQLI_CLIENT_SSL;" to "$tls_mode = MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;"

    Surely, there is a better way. Is there an env var that I missed? Any insight is appreciated.

    Many thanks for reading.
    Last edited by jjn; 07-05-2022, 00:39.
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    When you say "The Database however" at the start of the 4th paragraph, I think you mean "The web front-end" or something similar.

    There's some info you don't provide that might be relevant.
    1. what OS/distro and version is being used for your on-prem Zabbix web front-end
    2. what PHP version are you using?
    3. what security/encryption library is PHP linked to (hopefully OpenSSL, but for some distros, might not be) and what version of the library?
    The fact that you can set the flag to turn off verification of the server cert and that makes it work probably means that it's not an issue with algorithm mismatch, but knowing the versions involved may still provide a clue.

    If you enable PHP logging and increase the log level, do you get anything useful in the PHP logs? Anything similar to the 'SSL_CTX_set_default_verify_paths' that's reported in the thread you linked to? Even an obscure OpenSSL error at least gives something to go on.

    Comment

    • jjn
      Junior Member
      • May 2022
      • 5

      #3
      D'oh! Thank you, yes, I meant the web front-end. Editted the original post to reflect that and to identify the containers used, which were:
      • Server: zabbix/zabbix-server-mysql:ubuntu-6.0.3
      • Web front-end: zabbix/zabbix-web-nginx-mysql:ubuntu-6.0.3
      It's just using the included PHP (8, i think), and I'm assuming it's linked to OpenSSL, but I'll have to go confirm that and those versions.

      As for PHP errors, that's was a question that I forgot to ask. Where in the world do the PHP errors get logged to? It looked like stdout but there was nothing but nginx output in the container logs.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        php8 is not supported....Just saying...

        Comment

        • jjn
          Junior Member
          • May 2022
          • 5

          #5
          Ah, yes, looks like the provided Zabbix container (https://hub.docker.com/r/zabbix/zabbix-web-nginx-mysql) uses PHP 7.4.3, not 8.

          Using: php -r "phpinfo();"
          PHP Version => 7.4.3
          OpenSSL support = enabled
          OpenSSL Library Version = OpenSSL 1.1.1f 31 Mar 2020
          OpenSSL Header Version = OpenSSL 1.1.1f 31 Mar 2020


          Going to try adjusting the PHP logging to see if I can extract any additional insights.
          Last edited by jjn; 09-05-2022, 19:00.

          Comment

          Working...