我添加了nginx_stub_status配置后没有生效,报404
来源:6-2 ngx_http_stub_status监控连接信息

靈寶
2022-08-22
电脑是mac的,用brew安装的。检查了有模块。但是访问不生效。经过各种重启nginx,都不生效。(reload,stop再start,kill后再start都尝试了)
nginx_stub_status的模块检查:
这个是我的nginx_status配置,在conf.d文件夹下的一个配置文件中。
``
#这是一个扩展的配置文件,用于添加一些nginx的额外信息,比如监控
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /nginx_status {
stub_status on;
access_log off;
#allow 127.0.0.1;允许哪个ip可以访问
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
经过测试,只有nginx_status不可访问,是404。这个location /nginx_status
之前写的location = /nginx_status
,也是同样的效果。
``
curl http://127.0.0.1/nginx_status
404 Not Found
nginx/1.21.4
404 Not Found
写回答
1回答
-
靈寶
提问者
2022-08-22
重新复制了一份配置文件后,观察发现。是子配置文件和父配置文件的监听端口起冲突了,然后就忽略掉了子配置文件。
也就是说,同一个server(同IP+同port),出现多个前面的会强制忽略掉后面的。
(一开始我就注意到了这个,但是我看老师也有这个warn提示,没多想)
00
相似问题