以下是Filebeat配置SSL加密的通用步骤,适用于CentOS和Debian系统:
安装Filebeat
sudo yum install filebeatsudo apt-get install filebeat生成SSL证书(自签名示例)
sudo mkdir -p /etc/filebeat/certsopenssl req -x509 -newkey rsa:4096 -keyout /etc/filebeat/certs/ca.key -out /etc/filebeat/certs/ca.crt -days 3650 -nodesopenssl req -newkey rsa:4096 -keyout /etc/filebeat/certs/client.key -out /etc/filebeat/certs/client.csr -subj "/CN=filebeat_client"openssl x509 -req -in /etc/filebeat/certs/client.csr -CA /etc/filebeat/certs/ca.crt -CAkey /etc/filebeat/certs/ca.key -CAcreateserial -out /etc/filebeat/certs/client.crt -days 3650配置Filebeat
编辑 /etc/filebeat/filebeat.yml,在 output.elasticsearch 中添加SSL配置:
output.elasticsearch:
hosts: ["https://your-elasticsearch-host:9200"]
ssl.verification_mode: "full" # 启用完整验证
ssl.certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
ssl.certificate: "/etc/filebeat/certs/client.crt"
ssl.key: "/etc/filebeat/certs/client.key"
filebeat.inputs 中为输入源启用SSL(如需双向认证)。配置Elasticsearch(若需双向认证)
在 elasticsearch.yml 中添加:
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: "certificate"
xpack.security.transport.ssl.keystore.path: "elastic-certificates.p12"
xpack.security.transport.ssl.truststore.path: "elastic-certificates.p12"
(需将客户端证书导入Elasticsearch信任库,可使用 elasticsearch-certutil 工具)
重启服务并验证
sudo systemctl restart filebeatsudo systemctl restart elasticsearchtail -f /var/log/filebeat/filebeat注意:生产环境中建议使用受信任CA签发的证书,避免自签名证书的安全风险。