debian

Filebeat在Debian上如何配置SSL加密传输

小樊
41
2025-04-25 03:41:33
栏目: 云计算

要在Debian上配置Filebeat以使用SSL加密传输,请按照以下步骤操作:

  1. 安装Filebeat: 如果您尚未安装Filebeat,请按照官方文档中的说明进行安装:https://www.elastic.co/guide/en/beats/filebeat/current/install-debian.html

  2. 生成证书和密钥: 使用OpenSSL生成自签名证书和密钥。请确保将your_domain.com替换为您自己的域名。

    openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout filebeat.key -out filebeat.crt -subj "/CN=your_domain.com"
    

    这将在当前目录下生成filebeat.key(私钥)和filebeat.crt(证书)文件。

  3. 将证书和密钥复制到Filebeat配置目录: 将生成的证书和密钥文件复制到Filebeat的配置目录(通常位于/etc/filebeat)。

    sudo cp filebeat.key /etc/filebeat/filebeat.key
    sudo cp filebeat.crt /etc/filebeat/filebeat.crt
    
  4. 配置Filebeat: 编辑Filebeat配置文件(通常位于/etc/filebeat/filebeat.yml),以启用SSL加密传输。在output.elasticsearch部分添加以下设置:

    output.elasticsearch:
      hosts: ["your_elasticsearch_domain:9200"] # 替换为您的Elasticsearch域名和端口
      ssl.enabled: true
      ssl.certificate_authorities: ["/etc/filebeat/filebeat.crt"]
      ssl.certificate: "/etc/filebeat/filebeat.crt"
      ssl.key: "/etc/filebeat/filebeat.key"
    

    如果您的Elasticsearch集群使用客户端证书进行身份验证,请在setup.template.settings部分添加以下设置:

    setup.template.settings:
      index.number_of_shards: 3
      index.codec: best_compression
      _source.enabled: true
      process.template.levels: ["copy", "flatten"]
      discovery.seed_hosts: ["host1", "host2"] # 替换为您的Elasticsearch节点主机名或IP地址
      cluster.initial_master_nodes: ["node-1", "node-2"] # 替换为您的Elasticsearch主节点名称
    
  5. 重启Filebeat: 保存更改并重启Filebeat服务以应用新配置。

    sudo systemctl restart filebeat
    

现在,Filebeat应该已经配置为使用SSL加密传输数据到Elasticsearch。请注意,由于我们使用的是自签名证书,因此在连接到Elasticsearch时可能会收到安全警告。在生产环境中,建议使用权威证书颁发机构(CA)签发的证书。

0
看了该问题的人还看了