Sobes.tech
Middle+

How to make node_exporter work through port 443?

sobes.tech AI

Answer from AI

Node_exporter by default listens on port 9100 and does not support HTTPS or direct operation on port 443, as this usually requires root privileges to listen on privileged ports (<1024). To run node_exporter through port 443, you can use one of the following approaches:

  1. Proxy through a reverse proxy (e.g., Nginx or Apache)

    • Run node_exporter on the standard port (9100).
    • Configure a reverse proxy that listens on port 443 and proxies requests to node_exporter.
    • The proxy can provide TLS encryption.
  2. Use iptables to redirect port 443 to 9100

    • Set up a traffic redirection rule from port 443 to 9100.
    • Node_exporter continues to listen on 9100.
    • TLS is not provided by node_exporter itself in this case.
  3. Run node_exporter with elevated privileges (not recommended)

    • You can run node_exporter as root to listen on port 443, but this is insecure.

Example of configuring a reverse proxy on Nginx:

server {
    listen 443 ssl;
    server_name your.domain.com;

    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;

    location / {
        proxy_pass http://localhost:9100/;
        proxy_set_header Host $host;
    }
}

Thus, node_exporter runs on the standard port, and external access is through the secured port 443.