我正在尝试在 Ubuntu 14.04 上设置 nagios3 和 nginx,但遇到了一些问题,希望有人能帮我解决。我只看到一个空白页,而不是预期的 Nagios 页面。它似乎在提供 index.php 文件,但没有任何标签、文本或任何类型的数据。
我已经以非常标准的方式进行了设置,使用基本身份验证,并且基本上已经剪切和粘贴了配置。
nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
upstream php {
server unix:/var/run/php5-fpm.sock;
}
upstream fcgiwrap {
server unix:/var/run/fcgiwrap.socket;
}
}
虚拟主机文件:
server {
listen 80;
server_name nagios.domain.com;
access_log /var/log/nginx/nagios.access.log;
error_log /var/log/nginx/nagios.error.log info;
expires 31d;
root /usr/share/nagios3/htdocs;
index index.php index.html;
auth_basic "Nagios Restricted Access";
auth_basic_user_file /etc/nagios3/htpasswd.users;
rewrite ^/nagios3/images/(.*)$ /images/$1;
rewrite ^/nagios3/js/(.*)$ /js/$1;
location ~ \.css/?$ {
root /etc/nagios3/stylesheets/;
rewrite [/nagios3]?/stylesheets/(.*\.css)/?$ /$1;
}
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 unix:/var/run/fcgiwrap.socket;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
我在 /var/log/nginx/nagios.error.log 中收到以下错误:
2016/07/06 17:23:02 [info] 10022#10022: *5 client closed connection while waiting for request, client: 10.20.0.1, server: 0.0.0.0:80
index.php 位于预期的位置,并具有以下权限:
-rw-r--r-- 1 root root 1642 Jan 9 2014 index.php
这是现成的、开箱即用的 nagios index.php,无需修改。
sudo service fcgiwrap status 给我以下信息:
* Checking status of FastCGI wrapper fcgiwrap [ OK ]
如果有人能提供任何指导,我将不胜感激。
答案1
看起来你可能已经从[复制了你的代码]http://unix.rocks/2014/nginx-and-nagios-a-howto/],但是在 php 配置中遗漏了这一行:
include /etc/nginx/fastcgi.conf;