下面以 Filebeat 在 CentOS 上配置 TLS/SSL 证书 为例,分别说明 Filebeat → Elasticsearch / Logstash 两种常见场景,并给出完整配置示例和注意事项。
通常你需要以下文件:
ca.crt(用于验证服务端)client.crtclient.key假设证书放在:
/etc/filebeat/certs/
├── ca.crt
├── client.crt
└── client.key
⚠️ 权限建议:
chmod 600 /etc/filebeat/certs/*
chown root:root /etc/filebeat/certs/*
编辑:
vim /etc/filebeat/filebeat.yml
output.elasticsearch:
hosts: ["https://es-node1:9200"]
username: "filebeat"
password: "your_password"
ssl:
enabled: true
certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
certificate: "/etc/filebeat/certs/client.crt"
key: "/etc/filebeat/certs/client.key"
ssl:
enabled: true
certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
verification_mode: "full"
systemctl restart filebeat
systemctl status filebeat
input {
beats {
port => 5044
ssl => true
ssl_certificate => "/etc/logstash/certs/server.crt"
ssl_key => "/etc/logstash/certs/server.key"
ssl_certificate_authorities => ["/etc/logstash/certs/ca.crt"]
}
}
output.logstash:
hosts: ["logstash-host:5044"]
ssl:
enabled: true
certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
certificate: "/etc/filebeat/certs/client.crt"
key: "/etc/filebeat/certs/client.key"
仅用于测试:
ssl:
enabled: true
verification_mode: "none"
failed to load certificate
✅ 检查路径、权限、用户
x509: certificate is valid for xxx, not yyy
✅ 证书必须包含 ES/Logstash 的 hostname 或 IP
journalctl -u filebeat -f
或
tail -f /var/log/filebeat/filebeat
| 场景 | 必备证书 |
|---|---|
| Filebeat → ES | ca.crt |
| 双向 TLS | ca.crt + client.crt + client.key |
| Filebeat → Logstash | ca.crt |
| 双向 TLS | ca.crt + client.crt + client.key |
如果你愿意,可以告诉我:
我可以给你 完全贴合你环境的配置示例。