{"id":151567,"date":"2021-11-01T03:55:02","date_gmt":"2021-11-01T03:55:02","guid":{"rendered":"https:\/\/onet.com.vn\/?p=151567"},"modified":"2022-11-13T10:56:33","modified_gmt":"2022-11-13T10:56:33","slug":"cai-dat-ssl-https-grafana-centos-7","status":"publish","type":"post","link":"https:\/\/onet.com.vn\/cai-dat-ssl-https-grafana-centos-7\/","title":{"rendered":"C\u00e0i \u0111\u1eb7t SSL HTTPS Grafana Centos 7"},"content":{"rendered":"

Grafana SSL<\/h2>\n

SSL is not installed by default when using the free, self-hosted community edition. If you purchase the cloud version, then SSL is configured automatically by default. You will need sudo access to the servers\u00a0\/etc\/grafana\/grafana.ini<\/strong>\u00a0file. Look for the HTTP options:<\/p>\n

Grafana HTTP options<\/h2>\n

There are two key fields that need changing in the\u00a0Grafana.ini<\/strong>\u00a0file:<\/p>\n

[server]
\nhttp_addr = dashboard.yourdomain<\/strong>.co.uk
\nhttp_port = 3000
\ndomain = yourdomain.co.uk
\nroot_url = https:\/\/grafana.yourdomain<\/strong>.co.uk:3000
\ncert_key\u00a0<\/strong>= \/etc\/grafana\/grafana.key<\/code>
\nenforce_domain = False
\nprotocol\u00a0<\/strong>= https<\/code>
\nsocket =
\nenable_gzip = False
\ncert_file = \/etc\/grafana\/grafana.crt
\nstatic_root_path = public
\nrouter_logging = False<\/p>\n

Step 1 \u2013 Create an SSL Certificate<\/h2>\n

I am using Red Hat Linux, but this will work on CentOS as well. You may need to check your appropriate documentation if you are using another flavor of Linux.<\/p>\n

From the command line type:<\/p>\n

openssl genrsa -out grafana.key 2048\r\n<\/code><\/pre>\n

 <\/p>\n

You should see output like this:<\/p>\n

\"Grafana,<\/figure>\n

Step 2 \u2013 Generate a certificate signing request<\/h2>\n

From the command line type:<\/p>\n

openssl req -new -key grafana.key -out grafana.csr<\/code><\/pre>\n

 <\/p>\n

You should see output like this:<\/p>\n

\"Grafana,<\/figure>\n

Step 3 \u2013 Output the certificate<\/h2>\n

From the command line type:<\/p>\n

openssl x509 -req -days 365 -in grafana.csr -signkey grafana.key -out grafana.crt<\/code><\/pre>\n

 <\/p>\n

You should see output like this:<\/p>\n

\"Grafana,
Note: If you type\u00a0ls -l<\/strong>\u00a0you will see your certificates<\/figcaption><\/figure>\n

Step 4 \u2013 Set certificate key file ownership<\/h2>\n

From the command line type:<\/p>\n

sudo chown grafana:grafana grafana.crt\r\nsudo chown grafana:grafana grafana.key\r\nsudo chmod 400 grafana.key grafana.crt<\/code><\/pre>\n

 <\/p>\n

Step 5 \u2013 Move certificate and key file to the Grafana installation folder<\/h2>\n

From the command line type:<\/p>\n

sudo mv grafana.crt grafana.key \/etc\/grafana\/\r\n<\/code><\/pre>\n

 <\/p>\n

Step 6 \u2013 Edit the Grafana.ini file<\/h2>\n

From the command line type:<\/p>\n

sudo vim \/etc\/grafana\/grafana.ini<\/code><\/pre>\n