Hi Jacky,
We create the TLS certificates (.pem and .key) if we don't have valid ones:
# mkdir -p /etc/pki/tls/certs /etc/pki/tls/private
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/pki/tls/private/kibana-access.key -out /etc/pki/tls/certs/kibana-access.pem
Then, the /etc/nginx/conf.d/default.conf file is set to the following configuration:
server {
listen 80;
listen [::]:80;
return 301 https://$host$request_uri;
}
server {
listen 443 default_server;
listen [::]:443;
ssl on;
ssl_certificate /etc/pki/tls/certs/kibana-access.pem;
ssl_certificate_key /etc/pki/tls/private/kibana-access.key;
access_log /var/log/nginx/nginx.access.log;
error_log /var/log/nginx/nginx.error.log;
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/conf.d/kibana.htpasswd;
proxy_pass http://localhost:5601/;
}
}
It is necessary to restart the nginx service.
# systemctl restart nginx
Then, we create new credentials for the Kibana web page by using htpasswd:
# yum install httpd-tools
# htpasswd -c /etc/nginx/conf.d/kibana.htpasswd wazuh
On the other hand, the /etc/kibana/kibana.yml file is edited to set the following line:
server.host: "
localhost
"
as NGINX performs the port forwarding from the default 5601 to the secure 443.
After restarting the kibana service, the access to the Kibana WUI will be https://<kibana_server_IP>:443 and the web browser will ask us for the new credentials.
If SELinux is enabled, it can occur the "502 bad gateway" error. It will be necessary to allow NGINX to connect the Kibana port:
semanage port -a -t http_port_t -p tcp 5601
As you properly tested, although there is a Warning message related to the deprecated ssl directive, the NGINX configuration is OK:
# nginx -t