简介
prometheus主要侧重于监控,没有提供直接的认证能力,如果需要为其提供身份认证,可以通过配置反向代理达到目的,本文采用nginx配置的反向代理。
配置
安装nginx
略
配置nignx.conf
http {
server {
listen 80;
location / {
auth_basic "Prometheus";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://localhost:9090/;
}
}
}
认证用户
window下:
通过地址http://tool.oschina.net/htpasswd在线生成,输入用户名和口令选择SHA-1算法,生成用户名密码对,可以生成多组,一行一组放到auth_basic_user_file对应的文件中。
linux下:
mkdir -p /etc/nginx
htpasswd -c /etc/nginx/.htpasswd admin
启动服务
启动nginx
启动promethues
测试
浏览器访问 http://ip:12321/graph 测试
评论区