Ad Widget

Collapse

Zabbix 4 on Nginx Web Interface Wont Load

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ugbun
    Junior Member
    • Dec 2020
    • 3

    #1

    Zabbix 4 on Nginx Web Interface Wont Load

    Version Info:
    Debian GNU/Linux 10 (buster)
    Nginx 1.18.0
    Zabbix Server 4.0.21
    Php 7.3

    Hello,

    I recently started working for a new company. They used Zabbix but stopped about a year ago. Now they want it up and running again without losing their old configuration. The issue is that the server it runs on has gone through various updates in the year including switching from Apache to Nginx. The zabbix_server service starts and runs without errors. However, the web interface is not accessible. Nginx returns 502 Bad Gateway.

    I set up a Raspberry Pi as a small test device and I can get Zabbix running over Nginx without issues. However, using the same Nginx config file doesn't work on the main server. I've tracked down the issue to
    Code:
    /var/run/php/zabbix.sock
    . It simply doesn't exist on the server. I've run
    Code:
    sudo find / -name zabbix.sock
    and there are no results.

    The Nginx logs confirm this:
    Code:
    [crit] 5954#5954: *3566739 connect() to unix:/var/run/php/zabbix.sock failed (2: No such file or directory) while connecting to upstream
    How can I get the web interface back up and running? How can I reinstall zabbix.sock without losing the current configuration of Zabbix? If I upgrade to Zabbix 5, will the current configuration of the system be lost?

    Here is my Nginx config file:

    Code:
    server {
    listen 80;
    server_name zabbix.mycompany.com;
    
    root /usr/share/zabbix;
    
    index index.php;
    
    location = /favicon.ico {
    log_not_found off;
    }
    
    location / {
    try_files $uri $uri/ =404;
    }
    
    location /assets {
    access_log off;
    expires 10d;
    }
    
    location ~ /\.ht {
    deny all;
    }
    
    location ~ /(api\/|conf[^\.]|include|locale) {
    deny all;
    return 404;
    }
    
    location ~ [^/]\.php(/|$) {
    fastcgi_pass unix:/var/run/php/zabbix.sock;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    
    fastcgi_param DOCUMENT_ROOT /usr/share/zabbix;
    fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
    fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;
    
    
    include fastcgi_params;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    
    fastcgi_intercept_errors on;
    fastcgi_ignore_client_abort off;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    }
    }
  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #2
    Maybe this: https://www.datadoghq.com/blog/nginx...rrors-php-fpm/

    Check the php-fpm service state.

    Comment

    • Ugbun
      Junior Member
      • Dec 2020
      • 3

      #3
      LenR

      Good link! It helped me make progress but I'm not quite there yet.

      The issue with the missing sock was that the zabbix-php-fpm.conf file was missing from /etc/php/7.3/fpm/pool.d directory.

      I copied the file from my test machine and restarted php-fpm and now the socket is open. However, I get permission denied error in the nginx logs. I temporarily did a chmod 777 on zabbix.sock and the web gui came up so I can verify the socket is open and working. I can't leave the socket on 777 so I'll need to get the permissions figured out.

      Comment

      • Ugbun
        Junior Member
        • Dec 2020
        • 3

        #4
        Small update. This server has Nginx running under user nginx instead of the worker processes running under www-data. Changing the user and group in the zabbix-php-fpm.conf file to nginx fixed the permissions issue.

        Comment

        Working...