Nagios with nginx over https

This is the nginx conf which worked for me for running Nagios3 with nginx over https, just putting it up here for needy folks like me.
Considering following upstreams for php5-fpm and fcgiwrap:

upstream php {
	server unix:/var/run/php5-fpm.sock;

upstream perl {
	server unix:/var/run/fcgiwrap.socket;

Assuming both php5-fpm and fcgiwrap for perl cgi are running, create a conf file as below:

server {
	listen	443; 
	ssl	on;

	ssl_certificate		/etc/nginx/ssl/;
	ssl_certificate_key	/etc/nginx/ssl/;


	access_log /var/log/nginx/foo.com_access.log;
	error_log  /var/log/nginx/foo.com_error.log;

	root /usr/share/nagios3/htdocs;	
	index index.php index.html;

	auth_basic "Ngios Auth";
	auth_basic_user_file /etc/nagios3/htpasswd.users;
	location /nagios3/stylesheets {
		alias /etc/nagios3/stylesheets;

	location /stylesheets {
		alias /etc/nagios3/stylesheets;

	location /nagios3/images {
		alias /usr/share/nagios3/htdocs/images;

	location ~ \.cgi$ {
		root /usr/lib/cgi-bin/nagios3;
		rewrite ^/cgi-bin/nagios3/(.*)$ /$1;
		include /etc/nginx/fastcgi_params;
		fastcgi_param AUTH_USER $remote_user;
		fastcgi_param REMOTE_USER $remote_user;
		fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/nagios3$fastcgi_script_name;	
		fastcgi_pass perl;

	location ~ \.php$ {
		try_files $uri = 404;
		include /etc/nginx/fastcgi_params;
		fastcgi_pass php;

Don’t forget to put “try_files $uri = 404;” while fastcgi passing php for security reasons.

Notify of

Inline Feedbacks
View all comments