【问题标题】:Nginx Prometheus exporter fails to start with connection refused errorNginx Prometheus 导出器无法启动连接被拒绝错误
【发布时间】:2021-12-16 11:25:35
【问题描述】:

我在 Ubuntu 20.04 服务器上设置了 Nginx Inc. (https://github.com/nginxinc/nginx-prometheus-exporter) 的 Nginx Prometheus 导出器。 尝试启动服务,出现错误:

Could not create Nginx Client: failed to get https://domain.tld/nginx-status: Get "https://domain.tld/nginx-status": dial tcp 127.0.1.1:443: connect: connection refused

网址https://domain.tld/nginx-status 运行良好。

这是我正在使用的配置文件:

[Unit]
Description=Nginx Prometheus Exporter
After=network.target

[Service]
Type=simple
User=nginx_exporter
Group=nginx_exporter
ExecStart=/usr/local/bin/nginx-prometheus-exporter \
    -web.listen-address=server_IP:9113 \
    -nginx.scrape-uri https://domain.tld/nginx-status

SyslogIdentifier=nginx_prometheus_exporter
Restart=always

[Install]
WantedBy=multi-user.target

【问题讨论】:

  • 我看到domain.tld 已解析为127.0.1.1。如果 NGINX 和 exporter 在同一台机器上,检查 NGINX 是否监听这个 IP。如果它们在不同的服务器上,请检查/etc/hosts 导出器所在的domain.tld 条目。
  • “检查NGINX是否监听这个IP”是什么意思?如果 Nginx 也监听本地主机?目前它监听 PUBLIC_IP:80、PUBLIC_IP:443、0.0.0.0:8083 和 127.0.0.1:8084
  • 你有它。您的错误消息包含:dial tcp 127.0.1.1:443。这意味着,导出器没有使用公共 IP 连接到 NGINX,而是使用环回 IP。您需要更改 NGINX 配置,使其侦听端口 443 上的任何 IP,或者检查 /etc/hosts 并删除 domain.tld 到 127.0.1.1 的映射。
  • 如果你喜欢这样的话,你也可以将listen 127.0.1.1:443; 添加到 NGINX 配置中。

标签: prometheus


【解决方案1】:

所以问题是/etc/hosts 文件中的一个条目...

127.0.0.1 domain.tld

现在导出器正在启动,没有任何错误!

感谢@anemyte

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-23
    • 2011-04-25
    • 2017-04-28
    相关资源
    最近更新 更多