Nginx applications using reverse proxy

Hi,

I’m trying to use Nginx application on my Nginx server used for a reverse proxy for several websites.
I configured the agent and when I manually execute the script /usr/lib/check_mk_agent/local/nginx I get this error :

Traceback (most recent call last):
File “/usr/lib/check_mk_agent/local/nginx”, line 6, in
data = urllib2.urlopen(‘http://127.0.0.1/nginx-status’).read()
File “/usr/lib/python2.7/urllib2.py”, line 154, in urlopen
return opener.open(url, data, timeout)
File “/usr/lib/python2.7/urllib2.py”, line 435, in open
response = meth(req, response)
File “/usr/lib/python2.7/urllib2.py”, line 548, in http_response
‘http’, request, response, code, msg, hdrs)
File “/usr/lib/python2.7/urllib2.py”, line 473, in error
return self._call_chain(*args)
File “/usr/lib/python2.7/urllib2.py”, line 407, in _call_chain
result = func(*args)
File “/usr/lib/python2.7/urllib2.py”, line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

In my ngnix logs I have this :

==> error.log <==
2020/03/30 23:15:07 [error] 7137#7137: *246 open() “/usr/share/nginx/html/nginx-status” failed (2: No such file or directory), client: 127.0.0.1, server: 127.0.0.1, request: “GET /nginx-status HTTP/1.1”, host: “127.0.0.1”
==> access.log <==
127.0.0.1 - - [30/Mar/2020:23:15:07 +0200] “GET /nginx-status HTTP/1.1” 404 162 “-” “Python-urllib/2.7”

Why the script look for the file in /usr/share/nginx/html/nging-status ?

hereafter the server block I put in my file.conf

server {
listen 127.0.0.1:80;
server_name 127.0.0.1;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}

and when I try with curl :

and before I disabled access logs I get :
127.0.0.1 - - [30/Mar/2020:23:27:50 +0200] “GET /nginx_status HTTP/1.1” 200 101 “-” “curl/7.52.1”

dash vs. underscore?

It looks like the script expected http://127.0.0.1/nginx-status but you configured and curl-ed http://127.0.0.1/nginx_status

grrrrr so easy. thank you very much, it’s better now :

thanks again :+1:

1 Like