【发布时间】:2018-08-30 20:30:48
【问题描述】:
我有一个 nginx docker 镜像在随机端口 http://localhost:32774 上运行 我还有一个在http://localhost:9090/ 上运行的 prometheus docker 映像 我想在我的 prometheus 上看到我的 nginx 日志显示
我已经在我的 nginx 容器上设置了 nginx_status,当我 curl 时 当我在容器中时,我可以同时看到 Nginx 页面和 http://localhost/nginx_status 页面
我可以查看http://localhost:9090/graph --Prometheus 我可以在本地浏览器上查看http://localhost:32774 --- nginx 我无法查看http://localhost:32774/nginx_status -- 403 禁止访问 nginxexporter 背后的想法是什么?我将它作为在 localhost:9113 上运行的容器
我的目标是让 nginx 日志显示在 Prometheus 上
这是我的 default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
allow ::1;
deny all;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
【问题讨论】:
-
我通过删除deny all解决了403禁止
-
我确实想通过以下正常运行时间 http 请求和结果来监控我的 nginx 网络服务器,有多少失败的请求,我希望 Prometheus 这样做
标签: docker nginx prometheus