去dockerhup进行下载,注意:kibana,elasticsearch,logstash版本要一致
docker pull kibana:7.6.0
启动kibana容器
#将宿主机端口映射到容器内部端口
docker run --name kibana -p 5601:5601 -d kibana:7.6.0
进入kibana容器内部
docker exec -it -uroot 容器id /bin/bash
进入config目录,修改kibana.yml文件配置为
server.name: kibana
server.host: "0.0.0.0"
## 自己es的ip地址,若是windows下用docker安装的,由于docker容器隔离的原因,ip这里就写宿主机ip
elasticsearch.hosts: [ "http://es所在服务器ip(宿主机ip):9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
退出容器,重启容器即可
#退出容器
exit
##重启kibana容器
docker restart kibana容器id
最后访问http://自己的ip:5601/
**
kibana默认没有访问的权限控制,如果需要设置访问的账号密码,可以使用nginx配置代理来发布kibana。我尝试了此种方法没有成功,我用的是另一种方法,链接:https://blog.csdn.net/Ming13416908424/article/details/115617571**
用nginx代理的步骤
#安装httpd插件
yum install -y httpd
#使用htpasswd命令生成密码文件,密码文件应该放在nginx的
#目录下(我试过了,我生成在 /etc/nginx/conf.d/就没报错),其他路径会报错了
htpasswd -c /etc/nginx/conf.d/kibanapw user password
#重启nginx
docker restart nginx容器id
#然后再nginx配置文件里配置这两项
auth_basic “Authorized users only”;
auth_basic_user_file 密码文件的位置(最好写容器内路径,因为我喜欢顺便挂载文件到容器里的); # 密码文件
nginx.conf的配置文件
server {
listen 8077;
listen [::]:8077;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
auth_basic "Authorized users only";
auth_basic_user_file /etc/nginx/conf.d/kibanapw; # 密码文件
proxy_pass http://内网ip:5601;
#root /usr/share/nginx/html;
#index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}