How to use rewrite rule for Node exporter under Nginx Reverse Proxy?

Viewed 598

I have a usecase where node exporter is running under reverse proxy. Here is the snippet of my current configuration:

    location /node_exporter {
        proxy_pass    http://127.0.0.1:9100/metrics;
    }

This is running fine, but I want to implement it without metrics subpath, for which I did this change:

    location /node_exporter {
        proxy_pass    http://127.0.0.1:9100/;
    }

It is opening the initial page of node exporter with metrics button, but when clicked on it, redirects to /metrics instead of /node_exporter/metrics which inturn gives 404.

Please suggest on how to use the rewrite rule for this usecase.

1 Answers

The following site configuration should be enough

location /node_exporter {  
  proxy_pass    http://127.0.0.1:9100/;
}

as long the telemetry path is changed when starting the node_exporter

./node_exporter/node_exporter --web.telemetry-path="/node_exporter/metrics"

Related