首页 > 技术文章 > Grafana 修改为HTTPS方式登录

security-guard 2021-11-29 16:51 原文

Grafana 添加https证书

首先需要安装OpenSSL

yum install -y openssl

 第二步,创建certificates

[root@Huawei /etc/grafana]# openssl req -x509 -out server.crt -keyout server.key -newkey rsa:2048 -nodes -sha256 -days 10000
Generating a 2048 bit RSA private key
..............+++
.........+++
writing new private key to 'server.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN                        ## CN代表中国
State or Province Name (full name) []:beijing               ## 州或省名称
Locality Name (eg, city) [Default City]:beijing             ## 地方名字
Organization Name (eg, company) [Default Company Ltd]:xx.xx.xx.xx  ## 部署项目的ip
Organizational Unit Name (eg, section) []:xx.xx.xx.xx              ## 部署项目的ip
Common Name (eg, your name or your server's hostname) []:xx.xx.xx.xx ## 部署项目的ip
Email Address []:18611111111@126.com   ## 邮箱地址
[root@Huawei /etc/grafana]# ls
grafana.ini  ldap.toml  provisioning  server.crt  server.key

 查看生成的 crt 和 key 文件

开始配置grafana

[root@Huawei ~]# cat /etc/grafana/grafana.ini | grep -Ev "^$|#|;"
[paths]
[server]
protocol = https
cert_file = /etc/grafana/server.crt
cert_key = /etc/grafana/server.key

 重启Grafana

systemctl restart grafana-server.service 

 访问

 

 显示必须使用https

成功访问Grafana,使用https://grafana-zjt.com

推荐阅读