Solved nginx , serving zabbix & poudriere.

I want nginx to serve zabbix & poudriere.
No idea how to do so.
Here is my config file for zabbix,

Code:
cat nginx.conf
user  www www;
worker_processes  auto;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

server {
listen 80;
    server_name myfreebsd; # Change to your domain name or IP address

    index index.php index.html index.htm;

    # Allow caching static resources
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|woff|css|js|html)$ {
            add_header Cache-Control "public";
            expires 2d;
        }


    location / {
        try_files $uri $uri/ =404;
    }

    root /usr/local/www/zabbix74; # Ensure this matches your web root

    location ~\.php$ {
        fastcgi_pass 127.0.0.1:9000; # Use the IP address and port here
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

}

}
 
Zabbix is network monitoring, Nice to have, but does require some processing power. Let's leave Poudriere out for now, and focus on getting Zabbix to display the 'console' from which you can see network stats.

Did you get nginx to serve the basic index.html page? Is it visible where it needs to be visible? Start there.

But in all honesty, ask yourself if Zabbix even makes sense in your case. It may be a fun thing to set up and practice with, but unless you have several machines (like at least 5 machines or VMs), Zabbix does not make much sense to deploy.

Also, Zabbix is not critical for Poudriere. If you already have a working Poudriere setup, then Zabbix is a fun way/use case to monitor that. If you discuss what you want Zabbix to monitor, what you want to accomplish with Zabbix, that kind of drives how to configure Zabbix.

Otherwise, all I can say is try launching Zabbix according to setup instructions you find on the project's home page, look for error messages, and report the details here... I'm assuming you installed Zabbix from ports, rather than a straight tarball from upstream.
 
Currently is use zabbix with timescaledb(postgresql) backend. And it works nice. The polling frequency is set tp 15s. So it does not take much cpu.
With my config listed above i can see zabbix dashboard in the document root.
But now i also want to see poudriere logs served by nginx. But it has another document root. Two "root" is difficult in nginx.
The current 'root' is in the "server' block, not the 'location' block, that does not work good. Only for php files.
Another option would be to serve poudriere logs with apache.

For the sake of completeness an nginx poudriere config file, but it has another 'root',


Code:
/usr/local/share/examples/poudriere $ cat nginx.conf.sample
# Place these sections into the relevant nginx.conf or included files sections.

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    # Allow gzipping js, css, log, svg and json files.
    gzip on;
    gzip_http_version 1.0;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_min_length  1100;
    gzip_buffers 16 8k;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/gif image/jpeg image/png application/json image/svg+xml;

    types {
        text/plain                            log;
    }

    server {
        listen       0.0.0.0:80 accept_filter=httpready;
        server_name  poudriere.example.net accept_filter=httpready;
        root         /usr/local/share/poudriere/html;

        # Allow caching static resources
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|woff|css|js|html)$ {
            add_header Cache-Control "public";
            expires 2d;
        }

        location /data {
            alias /usr/local/poudriere/data/logs/bulk;

            # Allow caching dynamic files but ensure they get rechecked
            location ~* ^.+\.(log|txz|tbz|bz2|gz)$ {
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            }

            # Don't log json requests as they come in frequently and ensure
            # caching works as expected
            location ~* ^.+\.(json)$ {
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
                access_log off;
                log_not_found off;
            }

            # Allow indexing only in log dirs
            location ~ /data/?.*/(logs|latest-per-pkg)/ {
                autoindex on;
            }

            break;
        }
    }
}
 
Ok, solved with two server blocks,
Code:
cat nginx.conf
user  www www;
worker_processes  auto;

# This default error log path is compiled-in to make sure configuration parsing
# errors are logged somewhere, especially during unattended boot when stderr
# isn't normally logged anywhere. This path will be touched on every nginx
# start regardless of error log location configured here. See
# https://trac.nginx.org/nginx/ticket/147 for more info.
#
#error_log  /var/log/nginx/error.log;
#

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

server {
listen 127.0.0.1:8001;
    server_name myfreebsd; # Change to your domain name or IP address

    index index.php index.html index.htm;

    # Allow caching static resources
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|woff|css|js|html)$ {
            add_header Cache-Control "public";
            expires 2d;
        }


    location / {
        try_files $uri $uri/ =404;
    }

    root /usr/local/www/zabbix74; # Ensure this matches your web root

    # This block processes PHP files
    location ~\.php$ {
        fastcgi_pass 127.0.0.1:9000; # Use the IP address and port here
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

}

server {
        listen       127.0.0.1:8002 ;
        server_name  127.0.0.1 accept_filter=httpready;
        root         /usr/local/share/poudriere/html;

        # Allow caching static resources
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|woff|css|js|html)$ {
            add_header Cache-Control "public";
            expires 2d;
        }

        location /data {
            alias /usr/local/poudriere/data/logs/bulk;

            # Allow caching dynamic files but ensure they get rechecked
            location ~* ^.+\.(log|txz|tbz|bz2|gz)$ {
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            }

            # Don't log json requests as they come in frequently and ensure
            # caching works as expected
            location ~* ^.+\.(json)$ {
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
                access_log off;
                log_not_found off;
            }

            # Allow indexing only in log dirs
            location ~ /data/?.*/(logs|latest-per-pkg)/ {
                autoindex on;
            }

            break;
        }
    }



}
x@myfreebsd:/usr/local/etc/nginx $
 
I'd really suggest diagramming out how you want the whole enchilada to work. Like, one host for Poudriere, another for Zabbix... Well, even if they are on the same host, it's not out of question for one machine to serve up more than one site.

Just looking at the diagram, it tells you how to set up the software. That's what the 'divide and conquer' approach is all about, it will serve you well with troubleshooting and other problem solving.
 
Back
Top