netdata是一个漂亮的linux系统监控工具。如图。

如果将netdata部署在云服务上,为了安全和方便,可以在安全组禁止访问netdata默认端口,用nginx反向代理netdata,用三级域名实现对netdata的访问。nginx的配置如下:
server {
listen 80;
server_name www.zechno.tech;
return 301 https://$server_name$request_uri;
}
server {
listen 80;
server_name netdata.zechno.tech;
location ^~ / {
proxy_pass http://127.0.0.1:19999;
}
}
如果想将netdata作为一个子路径来访问,会发现报错如“File does not exist, or is not accessible: /usr/share/netdata/web/netdata”,错误原因是nginx将子路径名传递给了netdata,解决办法是,将netdata作为根目录服务,将其他服务作为子路径服务。配置如下:
server {
location /html/ {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ^~ {
proxy_pass http://127.0.0.1:19999;
}
}