网站首页 > 技术教程 正文
一、原因
因客户Red Hat 7.5服务器安装部署grafana无法添加prometheus数据源,以及无法修改初始密码,为确保环境访问安全,特别研究通过账号密码认证访问prometheus,搜索了很多资料,但都缺这缺那,所以我这里记录下具体实现过程:
二、安装部署httpd
方法一:使用yum安装
yum -y install apr apr-util httpd
方法二:使用源码安装
yum -y install expat-devel gcc gcc-c++ autoreconf libtoolize automake
1、下载httpd安装包
wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.46.tar.gz
2、解压
tar zxvf httpd-2.4.46.tar.gz
3、下载新的apr、apr-util安装(安装过程会有各种奇葩错误,自行搜索资料解决,这里不具体讲解)
wget http://mirror.bit.edu.cn/apache/apr/apr-1.7.0.tar.gz
wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
4、安装apr、apr-util
tar -zxvf apr-1.7.0.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-1.7.0
./configure --prefix=/usr/local/apr && make && make installc
./configure --prefix=/usr/local/apr-util && make && make install
5、进入目录cd httpd-2.4.46/
cd /opt/httpd-2.4.46/
./configure --prefix=/usr/local/apache2/ --enable-rewrite --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make && make install
三、创建prometheus访问认证账号密码
备注:路径与用户名及密码根据实际环境操作变更(在交互界面输入两次相同的密码)
/usr/bin/htpasswd -c /etc/nginx/.htpasswd promethues
四、配置nginx访问配置
vim /etc/nginx/conf/nginx.conf
location / {
auth_basic "Prometheus";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://localhost:9090;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root html;
index index.html index.htm;
}
/etc/nginx/sbin/nginx -t
/etc/nginx/sbin/nginx -s reload
五、修改prometheus.yml文件,配置basic auth认证
1、修改prometheus.yml文件
vim /usr/local/prometheus/prometheus.yml
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
basic_auth:
username: promethues
password: 密码
2、重启prometheus服务
systemctl restart prometheus
systemctl status prometheus
3、访问prometheus服务界面
4、输入配置的用户名与认证密码
5、查看targets信息
猜你喜欢
- 2024-10-10 【Nginx基础】Nginx对用户名和密码做限制的实现示例
- 2024-10-10 Centos7 环境下生成自签名 SSL 证书的具体过程:
- 2024-10-10 Nginx学习笔记(07) 限制特定用户访问的 auth_basic 模块
- 2024-10-10 elasticsearch 集群身份认证与用户鉴权
- 2024-10-10 学成在线 类慕课网 微服务教育网-第17天-讲义-用户认证 Zuul
- 2024-10-10 CA双向认证完整实现步骤(证书双向认证流程)
- 2024-10-10 自建CA和nginx实现ssl双向认证(nginx证书双向认证)
- 2024-10-10 Nginx 结合服务端实现下载文件鉴权
- 2024-10-10 「Kubernetes」第九章:认证(certified kubernetes admin)
- 2024-10-10 免费https证书申请及部署教程(https://sq.cfca.com.cn数字证书申请平台)
你 发表评论:
欢迎- 最近发表
-
- Win11学院:如何在Windows 11上使用WSL安装Ubuntu
- linux移植(Linux移植freemodbus)
- 独家解读:Win10预览版9879为何无法识别硬盘
- 基于Linux系统的本地Yum源搭建与配置(ISO方式、RPM方式)
- Docker镜像瘦身(docker 减小镜像大小)
- 在linux上安装ollama(linux安装locale)
- 渗透测试系统Kali推出Docker镜像(kali linux渗透测试技术详解pdf)
- Linux环境中部署Harbor私有镜像仓库
- linux之间传文件命令之Rsync傻瓜式教程
- 解决ollama在linux中安装或升级时,通过国内镜像缩短安装时长
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)