Skip to content

Self-hosted monitoring for homelabs: host and container metrics and uptime checks from all your machines in one dashboard, with an optional AI agent that diagnoses incidents and suggests fixes.

1.8 KB
Raw Blame
# Collector gateway: the only way to reach the collector endpoints when COLLECTOR_ACCESS=strict.
# It serves nothing else and is not attached to the reverse proxy's network.
#
#   :8081  vpn       publish this on your VPN address only (COLLECTOR_BIND), never on 0.0.0.0.
#                    Registration needs a join token from the dashboard's Connect a server button.
#   :8080  internal  for containers on this compose network (the dashboard machine's own
#                    collector). Never publish it: it accepts registration without a token.
#
# nginx sets X-Collector-Via itself; the backend trusts it only because nothing but this gateway
# and the frontend can reach the backend. No real_ip trust: a VPN client must not be able to spoof
# its address to dodge the per-IP rate limits.

server {
    listen 8081;
    server_name _;

    location ~ ^/api/monitoring/(collectors/register|collectors/register/poll|collectors/enroll|metrics/ingest|metrics/checks)$ {
        rewrite ^/api/(.*)$ /$1 break;
        proxy_pass http://backend:8000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Collector-Via vpn;
        proxy_read_timeout 60s;
        client_max_body_size 2m;
    }

    location / {
        return 404;
    }
}

server {
    listen 8080;
    server_name _;

    location ~ ^/api/monitoring/(collectors/register|collectors/register/poll|collectors/enroll|metrics/ingest|metrics/checks)$ {
        rewrite ^/api/(.*)$ /$1 break;
        proxy_pass http://backend:8000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Collector-Via internal;
        proxy_read_timeout 60s;
        client_max_body_size 2m;
    }

    location / {
        return 404;
    }
}