File nagios.nginx.conf of Package nagios

# Example Nagios configuration for nginx.  Edit to suit your environment
# and install as /etc/nginx/conf.d/nagios.inc, and then include it in
# the server context of nginx.conf or in a vhost.  (Do not name it nagios.conf
# or it will be included in the wrong place via the "include conf.d/*.conf;"
# directive.)
#
# This file was contributed to the openSUSE package, and is not part of the
# upstream Nagios distribution.

location /nagios {
	alias /usr/share/nagios;
	# switch-nagios-theme only updates Nagios cgi.cfg and apache, so also
	# change this alias when switching themes, e.g. change the above to:
	#alias /usr/share/nagios-themes/exfoliation;
	index index.php index.html;

	# If using an htpasswd file, it must be readable by nginx.
	# You may find the 'htpasswd' utility (part of the apache2-utils
	# package) useful for managing the htpasswd file.
	auth_basic "Nagios";
	auth_basic_user_file /etc/nagios/htpasswd.users;

	location ~ \.php$ {
                try_files      $uri =404;
		# NOT fastcgi.conf, which sets SCRIPT_FILENAME itself
                include        /etc/nginx/fastcgi_params;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME $request_filename;
                # php-fpm
                fastcgi_pass   127.0.0.1:9000;
        }
}

location /nagios/cgi-bin {
	alias /usr/lib/nagios/cgi;

	include /etc/nginx/fastcgi_params;
	fastcgi_param AUTH_USER $remote_user;
	fastcgi_param REMOTE_USER $remote_user;
	fastcgi_param SCRIPT_FILENAME $request_filename;

	# nginx only speaks FastCGI, not plain CGI, so you need a wrapper like
	# fcgiwrap <https://github.com/gnosek/fcgiwrap> or OpenBSD's slowcgi
	# <https://github.com/adaugherity/slowcgi-portable>.  Neither is
	# currently packaged in openSUSE, so you must use packages from
	# personal OBS projects, or install and activate manually.

	# fcgiwrap build deps: autoconf automake gcc pkg-config systemd-devel FastCGI-devel
	# Apply patch from https://github.com/gnosek/fcgiwrap/pull/39 before
	# running autoreconf -i; then run configure as:
	# ./configure CFLAGS="-I/usr/include/fastcgi -Wno-implicit-fallthrough"
	#
	# Edit fcgiwrap.service before 'make install' to fix the path, e.g.
	#	ExecStart=/usr/local/sbin/fcgiwrap
	# and set the User/Group (nginx/nginx, or wwwrun/www, etc.).
	#fastcgi_pass unix:/run/fcgiwrap.sock;
			# --OR--
	# slowcgi build deps: libevent-devel libbsd-devel
	# Follow the directions to build and install the RPM; set options in
	# the slowcgi sysconfig -- RTFM slowcgi(8).  Nagios doesn't support
	# running in a chroot, so you need at least '-p /'.
	fastcgi_pass unix:/run/nginx/slowcgi.sock;
}
openSUSE Build Service is sponsored by