diff --git a/nagios-nginx.conf b/nagios-nginx.conf new file mode 100644 index 0000000..0fa673f --- /dev/null +++ b/nagios-nginx.conf @@ -0,0 +1,24 @@ +server { + server_name nagios.your-domain.com; + root /usr/share/nagios/html; + listen 80; + index index.php index.html index.htm; + access_log /var/log/nginx/nagios.access.log; + error_log /var/log/nginx/nagios.error.log; auth_basic "Nagios Access"; + auth_basic_user_file /etc/nagios/private/htpasswd.users; + add_header X-Frame-Options "ALLOW"; location ~ \.php$ { + try_files $uri = 404; + fastcgi_index index.php; + fastcgi_pass unix:/run/php/php7.4-fpm.sock; + include fastcgi.conf; + } location ~ \.cgi$ { + root /usr/lib64/nagios/cgi-bin; + rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break; + fastcgi_param AUTH_USER $remote_user; + fastcgi_param REMOTE_USER $remote_user; + include fastcgi.conf; + fastcgi_pass unix:/run/fcgiwrap.socket; + } # Fixes the fact some links are expected to resolve to /nagios, see here. + location /nagios { + alias /usr/share/nagios/html; + }} diff --git a/nagios.spec b/nagios.spec index edb1f2e..7552694 100644 --- a/nagios.spec +++ b/nagios.spec @@ -4,7 +4,7 @@ Name: nagios Version: 4.4.14 -Release: 1mamba +Release: 2mamba Summary: An Open Source host, service and network monitoring program Group: Network/Monitoring Vendor: openmamba @@ -14,6 +14,7 @@ URL: https://www.nagios.org/ Source0: http://downloads.sourceforge.net/sourceforge/nagios/nagios-%{version}.tar.gz Source1: nagios.htaccess Source2: nagios.service +Source3: nagios-nginx.conf Patch0: %{name}-3.4.2-nagios_initscripts.patch Patch1: %{name}-3.4.2-makefile_install,patch Patch2: %{name}-3.4.2-fix_path_to_cgi_executables.patch @@ -54,8 +55,6 @@ This package provide core programs for nagios. Group: Network/Monitoring Summary: Provides the HTML and CGI files for the Nagios web interface Requires(pre): %{name} = %{?epoch:%epoch:}%{version}-%{release} -Requires(pre): apache -Requires(pre): apache-mod_php %description www Nagios is an application, system and network monitoring application. @@ -202,6 +201,11 @@ install -d %{buildroot}%{_sysconfdir}/nagios/conf.d #install -D -m0644 %{SOURCE2} %{buildroot}%{_unitdir}/nagios.service #rm -f %{buildroot}%{_initrddir}/nagios +mv %{buildroot}%{_sysconfdir}/httpd/httpd.d/nagios.conf{,.example} + +# install nginx sample site configuration +install -D -m0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/nginx/sites-available/nagios.conf.example + %clean [ "%{buildroot}" != / ] && rm -rf %{buildroot} @@ -239,28 +243,16 @@ fi find /etc/rc[0-6].d/ -type l -xtype l -exec rm -f {} \; : -%preun www -if [ $1 = 0 ]; then - [ -e %{_localstatedir}/lock/subsys/httpd ] && /sbin/service httpd reload 2>&1 -fi -exit 0 - %post www if [ $1 -eq 1 ]; then RANDOM_PASSWD=`/usr/bin/mkpasswd -l 10 -s 0 2>/dev/null` %{_bindir}/htpasswd \ -bc %{_sysconfdir}/%{name}/private/htpasswd.users nagiosadmin \ $RANDOM_PASSWD >/dev/null 2>&1 - groupmod nagios -A apache - systemctl -q reload httpd || : + #groupmod nagios -A apache + #systemctl -q reload httpd || : fi -exit 0 - -%postun www -if [ $1 -ge 1 ]; then - systemctl -q reload httpd || : -fi -exit 0 +: %files %defattr(-,root,root) @@ -285,14 +277,13 @@ exit 0 %files www %defattr(-,root,root) +%{_sysconfdir}/httpd/httpd.d/nagios.conf.example +%{_sysconfdir}/nginx/sites-available/nagios.conf.example +%attr(0640,root,%{nsgrp}) %config(noreplace) %{_sysconfdir}/%{name}/private/htpasswd.users %dir %{_datadir}/%{name}/html %{_datadir}/%{name}/html/* -#%config(noreplace) %{_datadir}/%{name}/html/config.inc.php -#%config(noreplace) %{_datadir}/%{name}/html/images/sblogo.png %dir %{_libdir}/nagios/cgi-bin %{_libdir}/nagios/cgi-bin/* -%config(noreplace) %{_sysconfdir}/httpd/httpd.d/nagios.conf -%attr(0640,root,%{nsgrp}) %config(noreplace) %{_sysconfdir}/%{name}/private/htpasswd.users %files devel %defattr(-,root,root) @@ -303,6 +294,9 @@ exit 0 %{_libdir}/nagios/libnagios.a %changelog +* Sat Aug 12 2023 Silvan Calarco 4.4.14-2mamba +- remove requirements for apache, added configuration for nginx + * Wed Aug 02 2023 Automatic Build System 4.4.14-1mamba - automatic version update by autodist