Welcome! Log In Create A New Profile

Advanced

alias error

Posted by luma 
alias error
November 06, 2011 01:13AM
Hello,

I am trying to setup Nginx with Nagios to monitor some servers.

I set it up following some online guides and trying to patch things together.

the issue now is that when you go to the url (lets say www.myserver.com/nagios) it tries to redirect it to: www.myserver.com/nagios/index.php/

in the error log (debug mode) I see it trying to access the file: /opt/nagios/share//index.php/index.php

I am using Nginx 1.0.9 on Debian 32 bit (I used apt to install nginx)

Nagios php files are in /opt/nagios/share

Here is my sites conf file for NginX:

[code]
server {
server_name www.myserver.com;

access_log /var/log/nginx/www.myserver.com.access.log;
error_log /var/log/nginx/www.myserver.com.error.log debug_http;


root /var/www/www.myserver.com;
index index.php index.html;

location / {
}

location /nagios {
auth_basic "Restricted";
auth_basic_user_file /opt/nagios/etc/htpasswd.users;
alias /opt/nagios/share/;
}

location ~ ^/nagios/(.*\.php)$ {
alias /opt/nagios/share/$1;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}

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/fcgiwrap.socket;
}
}
[/code]


nginx -V
nginx: nginx version: nginx/1.0.9
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/usr/src/nginx/source/nginx-1.0.9/debian/modules/nginx-echo --add-module=/usr/src/nginx/source/nginx-1.0.9/debian/modules/nginx-upstream-fair --add-module=/usr/src/nginx/source/nginx-1.0.9/debian/modules/nginx-syslog




Any ideas what is going on?

I don't want to use a separate conf file for Nagios, I would rather leave it in this one.

Thanks

Luma
Re: alias error
November 08, 2011 06:24AM
Try:

location ~ ^/nagios/(.*\.php)$ { # if it works you can adjust the matching, because you don't need the result
alias /opt/nagios/share; # should be in my opinion a folder, because nginx splits not the filename with alias
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}

T.
Re: alias error
November 09, 2011 01:53PM
Hello,

Thanks for the reply. I tried that and got the exact same result.

Here is a sample of the error log with debug on:

2011/11/09 18:45:15 [debug] 21538#0: *3 rewrite phase: 1
2011/11/09 18:45:15 [debug] 21538#0: *3 test location: "/"
2011/11/09 18:45:15 [debug] 21538#0: *3 test location: "nagios"
2011/11/09 18:45:15 [debug] 21538#0: *3 test location: ~ "^/nagios/(.*\.php)$"
2011/11/09 18:45:15 [debug] 21538#0: *3 test location: ~ "\.cgi$"
2011/11/09 18:45:15 [debug] 21538#0: *3 test location: ~ "\.php$"
2011/11/09 18:45:15 [debug] 21538#0: *3 using configuration "/nagios"
2011/11/09 18:45:15 [debug] 21538#0: *3 http cl:-1 max:1048576
2011/11/09 18:45:15 [debug] 21538#0: *3 rewrite phase: 3
2011/11/09 18:45:15 [debug] 21538#0: *3 post rewrite phase: 4
2011/11/09 18:45:15 [debug] 21538#0: *3 generic phase: 5
2011/11/09 18:45:15 [debug] 21538#0: *3 generic phase: 6
2011/11/09 18:45:15 [debug] 21538#0: *3 generic phase: 7
2011/11/09 18:45:15 [debug] 21538#0: *3 access phase: 8
2011/11/09 18:45:15 [debug] 21538#0: *3 access phase: 9
2011/11/09 18:45:15 [debug] 21538#0: *3 rc: 0 user: "nagiosadmin" salt: "blahblah"
2011/11/09 18:45:15 [debug] 21538#0: *3 post access phase: 10
2011/11/09 18:45:15 [debug] 21538#0: *3 try files phase: 11
2011/11/09 18:45:15 [debug] 21538#0: *3 content phase: 12
2011/11/09 18:45:15 [debug] 21538#0: *3 open index "/opt/nagios/share//index.php/index.php"
2011/11/09 18:45:15 [debug] 21538#0: *3 stat() "/opt/nagios/share//index.php/index.php" failed (20: Not a directory)
2011/11/09 18:45:15 [error] 21538#0: *3 "/opt/nagios/share//index.php/index.php" is not found (20: Not a directory), client: 75.155.215.56, server: FQDN, request: "GET /nagios/index.php/ HTTP/1.1", host: "FQDN"
2011/11/09 18:45:15 [debug] 21538#0: *3 http finalize request: 404, "/nagios/index.php/?" a:1, c:1
2011/11/09 18:45:15 [debug] 21538#0: *3 http special response: 404, "/nagios/index.php/?"
2011/11/09 18:45:15 [debug] 21538#0: *3 http set discard body
2011/11/09 18:45:15 [debug] 21538#0: *3 xslt filter header
2011/11/09 18:45:15 [debug] 21538#0: *3 HTTP/1.1 404 Not Found^M
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 208
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready