1、申请SSL证书
申请好域名证书,将证书文件上传至服务器
mkdir /usr/local/monitor/grafana-8.0.3/sslscp rules.tar.gz root@d-prometheus:/usr/local/monitor/grafana-8.0.3/ssl
2、修改grafana配置文件
$ vim /usr/local/monitor/grafana-8.0.3/conf/defaults.ini
......#################################### Server ##############################[server]# Protocol (http, https, h2, socket)protocol = https #修改为https# The ip address to bind to, empty will bind to all interfaceshttp_addr =# The http port to usehttp_port = 3000# The public facing domain name used to access grafana from a browserdomain = prometheus.123.top #添加要使用的域名# Redirect to correct domain if host header does not match domain# Prevents DNS rebinding attacksenforce_domain = false# The full public facing urlroot_url = %(protocol)s://%(domain)s:%(http_port)s/# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.serve_from_sub_path = false# Log web requestsrouter_logging = false# the path relative working pathstatic_root_path = public# enable gzipenable_gzip = false# https certs & key filecert_file =/usr/local/monitor/grafana-8.0.3/ssl/full_chain.pem #添加证书cert_key =/usr/local/monitor/grafana-8.0.3/ssl/private.key #添加证书......
3、测试访问
curl -I https://prometheus.123.top:3000HTTP/1.1 302 FoundCache-Control: no-cacheContent-Type: text/html; charset=utf-8Expires: -1Location: /loginPragma: no-cacheSet-Cookie: redirect_to=%2F; Path=/; HttpOnly; SameSite=LaxX-Content-Type-Options: nosniffX-Frame-Options: denyX-Xss-Protection: 1; mode=blockDate: Mon, 21 Jun 2021 09:35:06 GMT

