I am setting up a server as a Nagios monitoring server and I am running into an issue.
If I go to the url nagios.myserver.com/nagios/ (or nagios.myserver.com/nagios/index.php) the server tries to redirect to /opt/nagios/share/s/index.php
The correct folder is: /opt/nagios/share/
I have no idea where that /s/ is coming from.
Error log:
2011/11/06 00:16:28 [error] 1818#0: *13 open() "/opt/nagios/share/s/index.php" failed (2: No such file or directory), client: 75.xxxxxxxxxxxxxx, server: nagios.myserver.com, request: "GET /nagios/ HTTP/1.1", host: "nagios.myserver.com"
my /etc/nginx/sites-enabled/nagios.myserver.com.conf file:
server {
server_name nagios.myserver.com;
access_log /var/log/nginx/nagios.myserver.com.access.log;
error_log /var/log/nginx/nagios.myserver.com.error.log;
auth_basic "Restricted Nagios Area!";
auth_basic_user_file /opt/nagios/etc/htpasswd.users;
root /var/www/nagios.myserver.com;
index index.php index.html;
location / {
try_files $uri $uri/ index.php;
auth_basic "Restricted";
auth_basic_user_file /opt/nagios/etc/htpasswd.users;
}
location /nagios {
alias /opt/nagios/share/;
}
location ~ ^/nagios/(.*\.php)$ {
alias /opt/nagios/share/$1;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ \.cgi$ {
root /opt/nagios/sbin/;
rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
content of fastcgi.conf:
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (-f $request_filename) {
fastcgi_pass unix:/var/run/www/php.sock;
}
}
fastcgi_params:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
Debug:
2011/11/06 01:30:29 [debug] 5226#0: *1 open index "/opt/nagios/share/index.php"
2011/11/06 01:30:29 [debug] 5226#0: *1 internal redirect: "/nagios/index.php?"
2011/11/06 01:30:29 [debug] 5226#0: *1 generic phase: 1
2011/11/06 01:30:29 [debug] 5226#0: *1 test location: "/"
2011/11/06 01:30:29 [debug] 5226#0: *1 test location: "nagios"
2011/11/06 01:30:29 [debug] 5226#0: *1 test location: ~ "^/nagios/(.*\.php)$"
2011/11/06 01:30:29 [debug] 5226#0: *1 test location: ~ "\.php$"
2011/11/06 01:30:29 [debug] 5226#0: *1 using configuration "\.php$"
2011/11/06 01:30:29 [debug] 5226#0: *1 http cl:-1 max:1048576
2011/11/06 01:30:29 [debug] 5226#0: *1 generic phase: 3
2011/11/06 01:30:29 [debug] 5226#0: *1 http script complex value
2011/11/06 01:30:29 [debug] 5226#0: *1 http script copy: "/opt/nagios/share/"
2011/11/06 01:30:29 [debug] 5226#0: *1 http script capture: ""
2011/11/06 01:30:29 [debug] 5226#0: *1 http script copy: "/opt/nagios/share/"
2011/11/06 01:30:29 [debug] 5226#0: *1 http script capture: ""
2011/11/06 01:30:29 [debug] 5226#0: *1 http script var: "/opt/nagios/share/s/index.php"
2011/11/06 01:30:29 [debug] 5226#0: *1 http script copy: ""
2011/11/06 01:30:29 [debug] 5226#0: *1 http script file op 00000000 "/opt/nagios/share/s/index.php"
2011/11/06 01:30:29 [debug] 5226#0: *1 http script file op false
2011/11/06 01:30:29 [debug] 5226#0: *1 http script if
2011/11/06 01:30:29 [debug] 5226#0: *1 http script if: false
2011/11/06 01:30:29 [debug] 5226#0: *1 post rewrite phase: 4
2011/11/06 01:30:29 [debug] 5226#0: *1 generic phase: 5
2011/11/06 01:30:29 [debug] 5226#0: *1 generic phase: 6
2011/11/06 01:30:29 [debug] 5226#0: *1 generic phase: 7
2011/11/06 01:30:29 [debug] 5226#0: *1 access phase: 8
2011/11/06 01:30:29 [debug] 5226#0: *1 access phase: 9
I kept some of the debug out as I think this part should help though I still can't figure it out.
Any ideas?
I am pretty new to NginX.
Thanks.
It sounds like there is a rewrite rule somewhere in your config. What does
fastcgi.conf
look like?You can do a quick search with:
Try to change the
location /nagios
to thelocation /abc
to see if it redirects to the/opt/nagios/share/c/index.php
. If it doesn't, I suggest you turning on the debug and take a look the the error log.