生成Nginx密码文件

密码文件存放位置自定义,路径需记录下来,放在Nginx配置中。

printf "netdata:$(openssl passwd -apr1)" > /usr/local/nginx/conf/htpasswd

配置nginx.conf

upstream backend {
# the netdata server,请修改具体端口号
server 127.0.0.1:19999;
keepalive 64;
}

server {
# nginx listens to this
listen 80;

# the virtual host name of this,请求改具体域名
server_name netdata.example.com;

# auth password
auth_basic "netdata Login";
# 上一步生成的密码文件路径
auth_basic_user_file /usr/local/nginx/conf/htpasswd;

location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
}
}

转至https://tengwait.com/2020/08/20/Netdata%E5%85%A5%E9%97%A8/